Paso 7: Hacer que ambos LED parpadean!
Para este paso, repita los mismos pasos que el paso para configurar el LED verde.
* Recuerde ajustar ambos LED a modo de salida!
* No olvide apagar un LED cuando el otro está en!
¿Puede configurarla para que el LED verde permanece encendido durante 5 segundos y el LED amarillo por sólo 2 segundos?
Ejemplo:
// variables
// variables
int GREEN = 3;
int YELLOW = 4;
int DELAY_GREEN = 1000;
int DELAY_YELLOW = 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);
}voidloop()
{
// High turns things on
// Low turns things off
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
// how long we want the green led on
delay(DELAY_GREEN);
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
// how long we want the yellow led on
delay(DELAY_YELLOW);
}
int YELLOW = 4;
int DELAY_GREEN = 1000;
int DELAY_YELLOW = 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);
}voidloop()
{
// High turns things on
// Low turns things off
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
// how long we want the green led on
delay(DELAY_GREEN);
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
// how long we want the yellow led on
delay(DELAY_YELLOW);
}