Traffic Lights

While we all know traffic is a daily problem of our lifes, Gerardo Torres and I decided to work over one of the many dfficulties that cause traffic. Even though many of us think that there is no solution to traffic lights apart from bridges, but having a better timed traffic lights, taking in mind where the most traffic is made and the timing, traffic ights could get an improve. For our work we decided to make a traffic light using an arduino, some cables and programming for the arduino.

The next program is the one we used for the lights, you can change the timing and play around with the code:

const int VERDE = 4000;
const int PVERDE = 500;
const int RAMARILLO = 2000;

// Conexiones
int verde = 2;
int amarillo = 5;
int rojo = 11;
void setup() {
// Inicialización
digitalWrite(verde,LOW);
digitalWrite(rojo,HIGH);
digitalWrite(amarillo,LOW);

pinMode(verde,OUTPUT);
pinMode(amarillo,OUTPUT);
pinMode(rojo,OUTPUT);
}void loop() {
// Secuencia para semaforo 1
digitalWrite(verde,HIGH);
digitalWrite(amarillo,LOW);
digitalWrite(rojo,LOW);
delay(VERDE);
digitalWrite(verde,LOW);
delay(PVERDE);
digitalWrite(verde,HIGH);
delay(PVERDE);
digitalWrite(verde,LOW);
delay(PVERDE);
digitalWrite(verde,HIGH);
delay(PVERDE);
digitalWrite(verde,LOW);
delay(PVERDE);
digitalWrite(verde,HIGH);
delay(PVERDE);
digitalWrite(verde,LOW);
digitalWrite(amarillo,HIGH);
delay(RAMARILLO);
digitalWrite(amarillo,LOW);
digitalWrite(rojo,HIGH);
delay(5000);}


Deja un comentario