jueves, 7 de abril de 2016

Código del coche fantastico

/*
  CÓDIGO DEL SEMÁFORO
 */

// LED CONECTADO EN LAS PLACAS DE DE ARDUINO.
// DALE UN NOMBRE:
int led = 13;
int ledamarillo = 12;
int ledrojo = 11;

//  A CADA VARIABLE LE ASIGNAMOS UNA SALIDA
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
pinMode(ledamarillo, OUTPUT);
pinMode(ledrojo, OUTPUT); 
}

// SE HACE UN BUCLE O REPETICIÓN INDEFINIDA
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(100);               // wait for a second

  digitalWrite(ledamarillo, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(ledamarillo, LOW);    // turn the LED off by making the voltage LOW
  delay(100);               // wait for a second
  
 
  digitalWrite(ledrojo, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(ledrojo, LOW);    // turn the LED off by making the voltage LOW
  delay(100);               // wait for a second
 
    digitalWrite(ledamarillo, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(ledamarillo, LOW);    // turn the LED off by making the voltage LOW
  delay(100);               // wait for a second
 


}

No hay comentarios:

Publicar un comentario