Iniciar Sesion | Registrate

INICIO DE SESION

Usuario: *
Clave: *
Recordarme

Registro de Usuario

Los campos marcados con asterisco(*) son requeridos!
Su contraseña debe contener mas de 8 caracteres, un simbolo
y una letra en mayuscula.
Nombre: *
Usuario: *
Clave: *
Verifique su clave: *
Correo: *
Verifique su Correo: *
Marcar: *
Reload Captcha

EXPERIMENTO LUZ DE CONTROL DE TRAFICO CON PASE PEATONAL

Materiales necesarios:


 

Grafico de Conexión: 


 

 

Código:


 

 

// Variables

int carRed = 8;                  

int carYellow = 11;                 

int carGreen = 9;                 

int pedRed = 12;                   

int pedGreen = 10;                 

int pedBtn = 2;                   

int val = 0;                       

void setup() {                     

                pinMode(pedRed, OUTPUT);        

 pinMode(pedGreen, OUTPUT);      

 pinMode(carRed, OUTPUT);        

 pinMode(carYellow, OUTPUT);       

 pinMode(carGreen, OUTPUT);      

 pinMode(pedBtn, INPUT);      

}

void loop(){                  

                digitalWrite (pedRed, HIGH);    

 digitalWrite (carGreen, HIGH);

 val = digitalRead(pedBtn);   

 

  if (val == HIGH) {               

                               delay(2000);                   

                               digitalWrite(carGreen, LOW); 

                               digitalWrite(carYellow, HIGH); 

                               delay(3000);                  

                               digitalWrite(carYellow, LOW);  

                               digitalWrite(carRed, HIGH);  

                               delay(3000);                   

                               digitalWrite(pedGreen, HIGH); 

                               digitalWrite(pedRed, LOW);   

                               delay(10000);          

                               digitalWrite(pedGreen, LOW);


                        digitalWrite(pedRed, HIGH);

 

                        delay(3000);                

                        digitalWrite(carYellow, HIGH);

                        delay(3000);                   

                        digitalWrite(carYellow, LOW);

                        digitalWrite(carRed, LOW);  

     } 

 }