1

trying to get a little helper working. Two LEDs, each one is on for 24hrs. Only one is on at the time. There should be a button to switch the states of the LEDs without restarting the delay. Example: One LED turns on at midnight. In the mornin, somebody needs to turn that LED off and the other on, but the 24hrs delay should still be running without starting over. Is it possible to change the Output pins? Looked up and down google and cant figure it out. First Arduino project and only itsy bitsy programming knowledge. Heres the base of the Code without the button function

Im happy with every idea. Probably shouldnt be that hard, but im missing the logic with loops. Thanks everyone.


void setup()
{
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(4, INPUT);
}

void loop()
{
  digitalWrite(10, HIGH);
  delay(3000); 
  digitalWrite(10, LOW);
  delay(1000); 
  digitalWrite(9, HIGH);
  delay(3000); 
  digitalWrite(9, LOW);
  delay(1000);

3
  • Dont worry about the delay, i know its now set on 5min. Thats an easy change – Joel Feb 6 at 13:51
  • 1
    Most Arduino boards (there are many) are not good at keeping accurate time beyond several minutes. If time is important consider a Real Time Clock (RTC) module and reword your question accordingly. If time is not important, your next step is to create a state machine. Programming a state machine is usually considered a bit more advanced. Again, if this is what you want, reword your question accordingly. – st2000 Feb 6 at 14:16
  • of course it is possible to change the output pins ... your code does it, so it is unclear why you are asking ... to accomplish your task, set the state of the LEDs at every midnight .... then wait for button press ... if button is pressed, then change (or set) the state of the LEDs – jsotola Feb 6 at 20:01

Browse other questions tagged or ask your own question.