Paso 9: Haga todas las luces ir!
Para este paso, configurar el LED rojo del mismo modo que el LED amarillo.
* Recuerde que todos los LED a modo de salida!
* No olvide apagar LEDs cuando uno está en!
¿Puede configurarla para que el LED verde permanece encendida durante 5 segundos y el LED amarillo durante 2 segundos y luego el LED rojo durante 5 segundos?
Ejemplo:
// variables
// variables
int GREEN = 3;
int YELLOW = 4;
int RED = 5;
int DELAY_GREEN = 1000;
int DELAY_YELLOW = 1000;
int DELAY_RED = 1000;// basic functions
voidsetup()
{
// setup LED modes
// we're specifying that we're going to send information to this LED
pinMode(GREEN, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(RED, OUTPUT);
}voidloop()
{
// High turns things on
// Low turns things off
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, LOW);
// how long we want the green led on
delay(DELAY_GREEN);
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
digitalWrite(RED, LOW);
// how long we want the yellow led on
delay(DELAY_YELLOW);digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, HIGH);
// how long we want the red led on
delay(DELAY_RED);
}
int YELLOW = 4;
int RED = 5;
int DELAY_GREEN = 1000;
int DELAY_YELLOW = 1000;
int DELAY_RED = 1000;
// basic functions
voidsetup()
{
// setup LED modes
// we're specifying that we're going to send information to this LED
pinMode(GREEN, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(RED, OUTPUT);
}voidloop()
{
// High turns things on
// Low turns things off
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, LOW);
Cuánto tiempo queremos que el led verde
Delay(DELAY_GREEN);
digitalWrite (verde, baja);
digitalWrite (amarillo, alto);
digitalWrite (rojo, baja);
Cuánto tiempo queremos que el led amarillo
Delay(DELAY_YELLOW);
digitalWrite (verde, baja);
digitalWrite (amarillo, LOW);
digitalWrite (rojo, alto);
Cuánto tiempo queremos que el led rojo
Delay(DELAY_RED);
}