SIMULADOR SEMAFORO CON ARDUINO

// Semaforo de Arduino

// Declaracion de las variables

int rojo=2; //pin 2 led rojo
int naranja=3; //pin 3 led naranja
int verde=4; //pin 4 led verde

void setup()
{

// Configuramos los 3 pines como salidas digitales
pinMode(rojo,OUTPUT);
pinMode(naranja,OUTPUT);
pinMode(verde,OUTPUT);

}


void loop()
{
digitalWrite(naranja,LOW); // Apagamos el Led Naranja
digitalWrite(rojo,HIGH); // Encendemos el Led Rojo
delay(9000); // Esta en Rojo durante 9 segundos

digitalWrite(rojo,LOW); // Apagamos el Led Rojo
digitalWrite(verde,HIGH); // Encendemos el Led Verde
delay(8000); // Esta en Verde durante 8 segundos

digitalWrite(verde,LOW); // Apagamos el Led Verde
digitalWrite(naranja,HIGH); // Encendemos el Led Naranja
delay(1000); // Esta en Naranja durante 1 segundos

}