#define vm_c 22
#define Am_c 21
#define vd_c 19
#define Botao 34
#define Botao1 25
#define vm_c1 18
#define Am_c1 5
#define vd_c1 2
int flagsemaforo;
int statusBotao;
int statusBotao1;
void setup()
{
pinMode(vm_c, OUTPUT);
pinMode(Am_c, OUTPUT);
pinMode(vd_c, OUTPUT);
pinMode(Botao, INPUT);
pinMode(Botao1, INPUT);
pinMode(vm_c1, OUTPUT);
pinMode(Am_c1, OUTPUT);
pinMode(vd_c1, OUTPUT);
flagsemaforo = 1;
statusBotao = digitalRead(Botao);
statusBotao1 = digitalRead(Botao1);
}
void loop()
{
{
int flagBotao;
int flagBotao1;
flagBotao = digitalRead(Botao);
flagBotao1 = digitalRead(Botao1);
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_c1, HIGH);
digitalWrite( Am_c1, LOW);
digitalWrite( vd_c1, LOW);
delay(100);
}
if (flagsemaforo ==2 )
{
digitalWrite( vd_c, LOW);
digitalWrite( Am_c, HIGH);
digitalWrite( vm_c, LOW);
digitalWrite( vm_c1, HIGH);
digitalWrite( Am_c1, LOW);
digitalWrite( vd_c1, LOW);
delay(100);
}
if (flagsemaforo ==3 )
{
digitalWrite( vd_c, LOW);
digitalWrite( Am_c, LOW);
digitalWrite( vm_c, HIGH);
digitalWrite( vm_c1, LOW);
digitalWrite( Am_c1, HIGH);
digitalWrite( vd_c1, LOW);
delay(100);
}
if (flagsemaforo ==4 )
{
digitalWrite( vd_c, LOW);
digitalWrite( Am_c, LOW);
digitalWrite( vm_c, HIGH);
digitalWrite( vm_c1, LOW);
digitalWrite( Am_c1, LOW);
digitalWrite( vd_c1, HIGH);
delay(100);
}
if (flagBotao1 = digitalRead(Botao1))
{
digitalWrite( vd_c, LOW);
digitalWrite( vm_c, LOW);
digitalWrite( vm_c1, LOW);
digitalWrite( vd_c1, LOW);
}
if(flagBotao1)
{
digitalWrite(Am_c, HIGH);
delay(100);
digitalWrite(Am_c, LOW);
delay(100);
digitalWrite( vd_c, LOW);
delay(100);
}
}}