Semáforo
Práctica del Semáforo
Imagen de la disposición de los componentes
Código
int green = 13;
int yellow= 12;
int red=11;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(green, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(green, HIGH);
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
delay(1000);
digitalWrite(green, LOW);
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
delay(500);
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
digitalWrite(red, LOW);
delay(1000);
digitalWrite(yellow, LOW);
delay(250);
digitalWrite(yellow, HIGH);
delay(250);
digitalWrite(yellow, LOW);
delay(250);
digitalWrite(yellow, HIGH);
delay(250);
digitalWrite(yellow, LOW);
delay(250);
digitalWrite(yellow, HIGH);
delay(250);
digitalWrite(green, LOW);
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
delay(500);
digitalWrite(green, LOW);
digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
delay(1000);
digitalWrite(green, LOW);
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
delay(1000);
}
Comentarios
Publicar un comentario