Hi guys,
I`m very grateful for the help, but could not adapt the code of RIVA in my project.
This is my code. I tried to adjust the code RIVA but could not run the program.
//semáforo controlado pelo fluxo
const int BTNP1 = 2; //SENSOR VIA PRINCIPAL 1 (FLUXO)
const int BTNP2 = 3; //SENSOR VIA PRINCIPAL 2 (FLUXO)
const int BTNS1 = 4; //SENSOR VIA SECUNDÁRIA 1(FLUXO)
const int BTNS2 = 5; //SENSOR VIA SECUNDÁRIA 2(FILA CHEIA)
const int VDEP = 24; //SEMÁFORO VERDE DA VIA PRINCIPAL
const int AMP = 23; //SEMÁFORO AMARELO DA VIA PRINCIPAL
const int VERMP= 22; //SEMÁFORO VERMELHO DA VIA PRINCIPAL
const int VDES = 25; //SEMÁFORO VERDE DA VIA SECUNDÁRIA
const int AMS = 26; //SEMÁFORO AMARELO DA VIA SECUNDÁRIA
const int VERMS = 27; //SEMÁFORO VERMELHO DA VIA SECUNDÁRIA
int buttonstate;
const long debounceDelay = 20;
int semaf[]={ VDEP, AMP, VERMP, VDES, AMS, VERMS };
int i=0;
int length = sizeof semaf/sizeof *semaf;
void setup() {
for(int i=0;i<length ;i++)
pinMode(semaf[i], OUTPUT);
pinMode(BTNP1,INPUT);
pinMode(BTNP2,INPUT);
pinMode(BTNS1,INPUT);
pinMode(BTNS2,INPUT);
}
void loop(){
if (i==0){ //inicio
digitalWrite(VERMP, HIGH); //inicio
digitalWrite(VERMS, HIGH); //inicio
delay(5000); //inicio
digitalWrite(VERMP,LOW);
i=i+1;}
else;
mudaverdep();
mudavermelhop();
mudaverdes();
mudavermelhos();
}
void mudaverdep(){
digitalWrite(VERMP, LOW);
digitalWrite(VDEP, HIGH);
delay (5000);}
void mudavermelhop(){
digitalWrite(VDEP, LOW);
digitalWrite(AMP, HIGH);
delay (1000);
digitalWrite(AMP, LOW);
digitalWrite(VERMP, HIGH);
delay (1000);}
void mudaverdes(){
digitalWrite(VERMS, LOW);
digitalWrite(VDES, HIGH);
delay (5000);}
void mudavermelhos(){
digitalWrite(VDES, LOW);
digitalWrite(AMS, HIGH);
delay (1000);
digitalWrite(AMS, LOW);
digitalWrite(VERMS, HIGH);
delay (1000);}
What it takes to run?
This code is for a traffic light, releasing the flow, feeling the cars on the main road, and release to full queue (secondary route).