okay so my code looks a little messy (it is) and i've mixed a lot of things together (im very new to this whole thing) but ive written some notes an i would REALLY aprichiate somebody helping me:) So i have a ifraRed (motion detecter) conected to an led and i was able to make it all run smoothly, but something was wrong with the timing and i've tried a lot of different things and now i have kind of messes up my code:/ suggestions?
My suggestion would be to do what I do. Walk away. Come back tomorrow with fresh eyes. And then start over. Not sure what you're attempting to accomplish. But the following is what I believe is a cleaned up version of what you wrote for the void called "bool". I didn't change your flow. just made it compile as it was. And no. This won't do what you want it to do.
void someOtherName(){ //can't name it bool
if(digitalRead(pirPin) == HIGH) { //I think you meant something like this
digitalWrite(ledPin, HIGH); //missing semi-colon and extra ( at the beginning
while(ledPin == HIGH){ //I think you meant something like this
if(digitalRead(pirPin) == HIGH) {
digitalWrite(ledPin, HIGH); //missing semi-colon and extra ( at the beginning
while(ledPin == LOW){ //I think you meant something like this
if(digitalRead(pirPin) == HIGH) {
digitalWrite(ledPin, HIGH); //missing semi-colon and extra ( at the beginning
delay(2);
if(digitalRead(pirPin) == LOW){
digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state
while(ledPin == HIGH){ //I think you meant something like this
if(digitalRead(pirPin) == LOW) {
digitalWrite(ledPin, LOW); //missing semi-colon and extra ( at the beginning
while(ledPin == LOW){ //I think you meant something like this
if(digitalRead(pirPin) == LOW) {
digitalWrite(ledPin, LOW); //missing semi-colon and extra ( at the beginning
}
}
}
} //added a bunch of these to close all the ones above before the next void
} // now there are a bunch of extras at the bottom of the script
}
}
}
}
}
}
is. Even when the current output is high if the sensor is low it switches to low. I know this is supposed to happen without the code i am trying to write and it almost did (very unprecisly) in the beginning, but then i wanted to control the time the led was on and i kept changing thing so it got a little better and a little better at then a lot worse and now it looks like this (attachment bellow)
i am unbeliveably greatful that you are helping me!!!!!(even if you cant)
My questions are: what function is missing fro code i this text?