i'm still learning arduino. I'm trying to initialize a sequence of 3 leds lighting sequentially on button click. What I want is that the button acts as a switch switching on and off the sequence. So far I've done it but you have to keep the button pressed to keep it running.. I've tried another method by reading the button state after the sequence(all 3 leds) has finished, but I'm still not satisfied with that solution, since I want to be able to press the button switch ANY time during the sequence to turn the sequence off. Any help please? current code is below:
if(new_btn_state3 != old_btn_state3 && new_btn_state3 == HIGH){
test= true;
}
if(test){
analogWrite(LED10, 255);
digitalWrite(LED10, HIGH);
delay(100);
digitalWrite(LED10, LOW);
digitalWrite(LED12, HIGH);
delay(100);
digitalWrite(LED12, LOW);
digitalWrite(LED13, HIGH);
delay(100);
digitalWrite(LED13, LOW);
delay(50);
}
test is just a boolean i was testing with..
I think that to achieve what I really want I must use some type of multi-threading maybe? I don't know.. want to hear from u guys first..