Hello, i am very new to the arduino community.
I tried the search but don't found an answer.
My question is regarding an I hope easy code.
I want to turn on an LED with one time pushing a button and pushing again the LED turns off.
The code is working very well but I don't understand the actions in detail at one specific point.
if (readingbutton == HIGH && previousutton == LOW && millis() - timeLED > debounce) {
if (LEDState == HIGH)
LEDState = LOW;
else
LEDState = HIGH;
timeLED = millis();
}
when the button is pushed the code checks if the the LED is on or off.
If on turn it off
if off turn it on.
When does the code set timeLED = millis() ?
only if the first if is true, or?
or only if LEDSate is LOW so the path is going through the else?
Thank you very much, I enjoyed always the moment when my code is working like I want.
See "Style Guide" section, oh what the heck, read the whole thing.
.
There are very good tipps and I found some "bad" code in my own examples that I could correct now or optimize.
Thanks, that is a very helpfull side with a lot of tipps (I only understand a little bit of this codes but that codes which I understand a very helpfull at all.)
Now you guys have clarified my problem and gave some tipps for better coding in the future.