here is my code:
void setup() {
// put your setup code here, to run once:
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(6,INPUT);
pinMode(7,OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
if(digitalRead(3))
{
digitalWrite(7, HIGH);
delay(120000);
digitalWrite(7, LOW);
}
else if(digitalRead(4))
{
digitalWrite(7, HIGH);
delay(240000);
digitalWrite(7, LOW);
}
else if(digitalRead(5))
{
digitalWrite(7, HIGH);
delay(360000);
digitalWrite(7, LOW);
}
else if(digitalRead(6))
{
digitalWrite(7, HIGH);
delay(480000);
digitalWrite(7, LOW);
}
else
{
digitalWrite(7, LOW);
}
}
the photograph of the circuit is attached and made using tinkercad.com
the circuit is simple
an amount of delay is produced according to the switch pressed.
i.e., the light should glow only for that prescribed time.
i don't understand the mistake here and also when one key is pressed the other keys should be deactivated. please help me out