domingo, 6 de mayo de 2018

Semaforo Arduino



// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);                       // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);                       // wait for a second
  digitalWrite(12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(12, LOW);    // turn the LED off by making the voltage LOW
  delay(1000); 
  digitalWrite(11, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);                       // wait for a second
  digitalWrite(11, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);    
}
Explicación: Gracias al programa de arduino hemos podido imitar las luces de un semáforo (rojo, ámbar y verde). Para ello se necesitaran tres bombillas de colores (preferiblemente rojo verde y amarillo), siete cables para conectarlo todo a la placa de arduino y por último una placa protoboard.



No hay comentarios:

Publicar un comentario

Pulsador led 5 segundos

nt pulsador=2; int led=3; int ld=4; void setup() {   pinMode (pulsador,INPUT);    pinMode (led,OUTPUT);   digitalWrite (led,H...