-1
I’m new to programming.... The program I’m trying to write to run on the Arduino, will command a circuit that has two buttons. The 1 button is to turn on an Led and it runs the sequence of flashes. The other, must turn off the whole system. The first button worked, but I can’t get the second button to turn off the LED. Can anyone help?
int led1 = 13;
int botao1 = 7;
int botao2 = 2;
int estadobotao1 = 0;
int estadobotao2 = 0;
void setup()
{
pinMode(led1, OUTPUT);
pinMode(botao1, INPUT);
pinMode(botao2, INPUT);
}
void loop()
{
estadobotao1 = digitalRead(botao1);
if (estadobotao1 == HIGH) {
while(estadobotao2 == LOW){
digitalWrite(led1, HIGH);
delay(300);
digitalWrite(led1,LOW);
delay(300);
digitalWrite(led1, HIGH);
delay(300);
digitalWrite(led1,LOW);
delay(300);
digitalWrite(led1, HIGH);
delay(500);
digitalWrite(led1,LOW);
delay(500);
digitalWrite(led1, HIGH);
delay(500);
digitalWrite(led1,LOW);
delay(500);
estadobotao2 = digitalRead(botao2);
}
}
if(estadobotao2 == HIGH){
digitalWrite(led1,LOW);
}
}
Good evening! Thanks for the reply.... I could not understand friend... The button 2 in series with whom?
– Tales Vitor