#define vd_c 21
#define Am_c 19
#define vm_c 18
#define Botao 25
#define vm_p 4
#define vd_p 2
int flagsemaforo;
int statusBotao;
void setup()
{
pinMode(vm_c, OUTPUT);
pinMode(Am_c, OUTPUT);
pinMode(vd_c, OUTPUT);
pinMode(Botao, INPUT);
pinMode(vm_p, OUTPUT);
pinMode(vd_p, OUTPUT);
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(vm_p, HIGH);
delay(100);
}
if (flagsemaforo ==2 )
{
digitalWrite( vd_c, LOW);
digitalWrite( Am_c, HIGH);
digitalWrite( vm_c, LOW);
digitalWrite(vm_p,HIGH);
delay(100);
}
if (flagsemaforo ==3 )
{
digitalWrite( vd_c, LOW);
digitalWrite( Am_c, LOW);
digitalWrite( vm_c, HIGH);
digitalWrite( vd_p, HIGH);
digitalWrite( vm_p, LOW);
delay(100);
}
delay(200);
}}