I have system connected to an Arduino Uno where I want to read whether the switch is open or closed.
Based on if the switch is open/closed, I want an LED light to turn on/off. When the switch is open, the LED turns on and pushing the button turns it off and stays off for 24 hours then turns back on if the switch is still open and I can again turn off the light with one push of the button. However, if the switch is closed within the 24 hours, the light doesn't turn on and pushing the button does not do anything.
I don't know how to change the state of the LED back on after the 24 hours. Should I use a button counter, if
statements, or while
statements? I'm really new to coding and took on a large project I'm not sure how to complete. This is obviously a very small portion of the project. Any help is much appreciated.
This is as far as I've gotten. When the switch is open the LED turns on, but when I push the button, the light just dims. I also have to hold the button down to keep the light "off" and it turns right back on when I release the button.
if (digitalRead(switch) == LOW) {
digitalWrite(Light, HIGH );
if (digitalRead(Button) == LOW) {
digitalWrite(Light, LOW);
}
else if (digitalRead(switch) == HIGH) {
digitalWrite(Light, LOW );
}
}
switch
.