#define Vm_c 21
#define Am_c 19
#define Vd_c 18
#define Botao 25
#define Pvm_c 2
#define Pvd_c 4
int statusBotao;
int flagSemaforo;
void setup()
{
pinMode(Vm_c, OUTPUT);
pinMode(Am_c, OUTPUT);
pinMode(Vd_c, OUTPUT);
pinMode(Pvm_c, OUTPUT);
pinMode(Pvd_c, OUTPUT);
pinMode(Botao, INPUT);
flagSemaforo = 1;
statusBotao = digitalRead(Botao);
}
void loop ()
{
int flagBotao;
flagBotao = digitalRead(Botao);
if ((flagBotao == HIGH) && (statusBotao == LOW))
{
if (flagSemaforo <= 3)
{
flagSemaforo = flagSemaforo + 1;
}
else
{
flagSemaforo = 1;
}
}
statusBotao = flagBotao;
if (flagSemaforo == 1)
{
digitalWrite(Vd_c, HIGH);
digitalWrite(Am_c, LOW);
digitalWrite(Vm_c, LOW);
digitalWrite(Pvm_c, HIGH);
digitalWrite(Pvd_c, LOW);
delay(10);
}
if (flagSemaforo == 2)
{
digitalWrite(Vd_c, LOW);
digitalWrite(Am_c, HIGH);
digitalWrite(Vm_c, LOW);
digitalWrite(Pvm_c, HIGH);
digitalWrite(Pvd_c, LOW);
delay(10);
}
if (flagSemaforo == 3)
{
digitalWrite(Vd_c, LOW);
digitalWrite(Am_c, LOW);
digitalWrite(Vm_c, HIGH);
digitalWrite(Pvm_c, LOW);
digitalWrite(Pvd_c, HIGH);
delay(10);
}
delay(20);
}