Hi everyone,
I created this design of LEDs that work to the rhythm of music.
Everything works perfectly, but I would like to insert a function, which after a few seconds does not receive any input, all the LEDs come back on. when the sensor receives the input again it will resume the function of going to the rhythm of music.
Can you help me find a way to do it?
I insert a part of code with only one led in operation
int soundSensor=2;
int LED1=7;
boolean LEDStatus=false;
void setup() {
pinMode(soundSensor,INPUT);
pinMode(LED1,OUTPUT);
}
void loop() {
// ----------------1
int SensorData=digitalRead(soundSensor);
if(SensorData==1){
if(LEDStatus==false){
LEDStatus=true;
digitalWrite(LED1,HIGH);
}
else{
LEDStatus=false;
digitalWrite(LED1,LOW);
}
}
}