Hi
I'm pretty new to Arduino and I'm trying to create my first project.
It's going well but I need some help with an specific function.
The idea for this project is that there are 2 momentary switches.
- Pressing button1 will turn on led1
- Pressing button2 will turn on led2
- If they are both pressed within 1 second, it should blink both.
Any idea on how could I make it "wait" for the second button?
Thanks
void loop() {
// Acao caso o toque seja acionado
unsigned long currentMillis = millis();
if (digitalRead(button1) == LOW {
// How can I wait for 1 second here?
if (digitalRead(button2) == LOW {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
delay(1000);
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
delay(500);
}
else
digitalWrite(LED1, HIGH);
delay(1000);
Thanks