yet another question - is it possible to make the two run together I'm mean that the sensor will keep working even if nobody is connected to him?because now - only after I'm connecting to server at ip 10.0.0.155 it's start working...

if (digitalRead(PIRChannel) ==HIGH) // no movement - Green LED { digitalWrite(RedLED, LOW); digitalWrite(GreenLED,HIGH); // If you change d here... d=0; } else { digitalWrite(GreenLED,LOW); // Movement - Red LED digitalWrite(RedLED,HIGH); // ...you need to change d here too. d=1; // I would do this delay somewhere else in the code, or remove it // it can't respond to the web server requests while in this delay delay(5000); } }

Then move the call to pir_cheak() before the // listen for incoming clientsremark.

add: I would also add another variable to track the status of the pir pin. If there is motion, set the variable to 1. Don't set that variable to zero until you load the webpage. That way you will know two things. If there is motion now (d), and if there was motion since the last download (your new variable).

Inside the while loop, you never change d. If d ever were 1, you'd go into an infinite loop.

Quote

but now it doesn't work at all

By now, you'd think that you would have figured out that the code is doing something. You want it to do something. Presumably, "it doesn't work" means that those two somethings are not the same thing. So, if you ever get around to telling us what those two somethings are, then we can get to the point where the two somethings ARE the same thing.

pir_cheak() is defined to return an int. So, where is the necessary return statement? Why don't you expect, and use, the returned value?

O.K this is way I'm asking here , I'm new at this and if I do something wrong I need someone tell that - so I'll learn for the next time.

All I want to do is simple thingwhen the sensor is "on" - he will print out a message --> MOVE!!!! , red led will go on and green offwhen the sensor is off - he will print out --> ALL GOOD!!!!! , green led will go on and red off

if I do this only with serial.print - it's work fine.

the problem begin when I want to use the card as a server.and start to write HTML code.I hope now you understand.

now it is almost working like I want to.2 more things I want to know how to do1. I want the redLED will be on from 5 sec. where do I need to put the delay? now the led is not stable when there is a movement.2. I want that the error message will be written in the side - I need to get the RTC next week and I want to when ever there is a movement it will "save" me the time .

// when there is motion and you turn on the LED, do thisupdateTime = millis();updateTime += 5000;// Now call millis in the "turn off" section and compare the value returned to updateTimeif(updateTime < millis()){ // it has been 5 seconds // you can turn off the LED}

if I'm using the web response option - where do I put the int? at the pir_cheak function?

and another thing - I'm trying to keep the message at screen as long as the red LED is on.and it's doesn't doing it - it only write the message once , and then return to "all-good"( this is not good)I need the message will stay as long as the led is on. I have change a few thing but still no good