Paso 2: Luces de Navidad
Ahora que entendí un poco de lille más quería jugar y explorar algunas posibilidades.
Observar que las columnas de puño dos son de la misma. pero añade tres salidas más y trató de hacer que funcione como las luces de Navidad.
Copie y pegue el código siguiente.
int led2 = 2;
led3 int = 3; int del = 1000; led4 int = 4; led5 int = 5; led6 int = 6; led7 int = 7; led8 int = 8; led9 int = 9; led10 int = 10; led11 int = 11; led12 INT = 12; int led13 = 13;
la puesta en marcha ejecuta rutina una vez al presionar reset:
void setup () {/ / inicializar el pin digital como oupput.
pinMode (led2, salida); pinMode (led3, salida); pinMode (led4, salida); pinMode (led5, salida); pinMode (led6, salida); pinMode (led7, salida); pinMode (led8, salida); pinMode (led9, salida); pinMode (led10, salida); pinMode (led11, salida); pinMode (led12, salida); pinMode (led13, salida); }
TODO EN
void loop() {digitalWrite (led2, alto); delay(del); digitalWrite (LED 3, alto); delay(del/2); digitalWrite (led4, alto); delay(del/3); digitalWrite (led5, alta); delay(del/4); digitalWrite (led6, alta); delay(del/5); digitalWrite (led7, alto); delay(del/6); digitalWrite (led8, alto); delay(del/7); digitalWrite (led9, alto); delay(del/8); digitalWrite (led10, alto); delay(del/9); digitalWrite (led11, alto); delay(del/10); digitalWrite (led12 ALTO); Delay(del/11); digitalWrite (led13, HIGH); Delay(del);
APAGAR TODAS
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); Delay(del/3); digitalWrite (LED 3, alto); Delay(del/3); digitalWrite (led4, HIGH); Delay(del/3); digitalWrite (led5, HIGH); Delay(del/3); digitalWrite (led6, HIGH); Delay(del/3); digitalWrite (led7, HIGH); Delay(del/3); digitalWrite (led8, HIGH); Delay(del/3); digitalWrite (led9, HIGH); Delay(del/3); digitalWrite (led10, HIGH); Delay(del/3); digitalWrite (led11, HIGH); Delay(del/3); digitalWrite (led12, HIGH); Delay(del/3); digitalWrite (led13, HIGH); Delay(del);
APAGAR TODAS
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); digitalWrite (led6, HIGH); digitalWrite (led7, HIGH); digitalWrite (led8, HIGH); digitalWrite (led9, HIGH); digitalWrite (led10, HIGH); digitalWrite (led11, HIGH); digitalWrite (led12, HIGH); digitalWrite (led13, HIGH);
Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); digitalWrite (led6, HIGH); digitalWrite (led7, HIGH); digitalWrite (led8, HIGH); digitalWrite (led9, HIGH); digitalWrite (led10, HIGH); digitalWrite (led11, HIGH); digitalWrite (led12, HIGH); digitalWrite (led13, HIGH);
Delay(del/4); digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); Delay(del/5); digitalWrite (LED 3, alto); Delay(del/5); digitalWrite (led4, HIGH); Delay(del/5); digitalWrite (led5, HIGH); Delay(del/5); digitalWrite (led6, HIGH); Delay(del/5); digitalWrite (led7, HIGH); Delay(del/5); digitalWrite (led8, HIGH); Delay(del/5); digitalWrite (led9, HIGH); Delay(del/5); digitalWrite (led10, HIGH); Delay(del/5); digitalWrite (led11, HIGH); Delay(del/5); digitalWrite (led12, HIGH); Delay(del/5); digitalWrite (led13, HIGH); Delay(del);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); Delay(del/5); digitalWrite (LED 3, alto); Delay(del/5); digitalWrite (led4, HIGH); Delay(del/5); digitalWrite (led5, HIGH); Delay(del/5); digitalWrite (led6, HIGH); Delay(del/5); digitalWrite (led7, HIGH); Delay(del/5); digitalWrite (led8, HIGH); Delay(del/5); digitalWrite (led9, HIGH); Delay(del/5); digitalWrite (led10, HIGH); Delay(del/5); digitalWrite (led11, HIGH); Delay(del/5); digitalWrite (led12, HIGH); Delay(del/5); digitalWrite (led13, HIGH); Delay(del);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4); digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); digitalWrite (led6, HIGH); digitalWrite (led7, HIGH); digitalWrite (led8, HIGH); digitalWrite (led9, HIGH); digitalWrite (led10, HIGH); digitalWrite (led11, HIGH); digitalWrite (led12, HIGH); digitalWrite (led13, HIGH);
Delay(del/4); digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4); digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); digitalWrite (led6, HIGH); digitalWrite (led7, HIGH); digitalWrite (led8, HIGH); digitalWrite (led9, HIGH); digitalWrite (led10, HIGH); digitalWrite (led11, HIGH); digitalWrite (led12, HIGH); digitalWrite (led13, HIGH);
Delay(del/4); digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); Delay(del/5); digitalWrite (LED 3, alto); Delay(del/5); digitalWrite (led4, HIGH); Delay(del/5); digitalWrite (led5, HIGH); Delay(del/5); digitalWrite (led6, HIGH); Delay(del/5); digitalWrite (led7, HIGH); Delay(del/5); digitalWrite (led8, HIGH); Delay(del/5); digitalWrite (led9, HIGH); Delay(del/5); digitalWrite (led10, HIGH); Delay(del/5); digitalWrite (led11, HIGH); Delay(del/5); digitalWrite (led12, HIGH); Delay(del/5); digitalWrite (led13, HIGH); Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4); digitalWrite (led13, HIGH); Delay(del/5); digitalWrite (led12, HIGH); Delay(del/5); digitalWrite (led11, HIGH); Delay(del/5); digitalWrite (led10, HIGH); Delay(del/5); digitalWrite (led9, HIGH); Delay(del/5); digitalWrite (led8, HIGH); Delay(del/5); digitalWrite (led7, HIGH); Delay(del/5); digitalWrite (led6, HIGH); Delay(del/5); digitalWrite (led5, HIGH); Delay(del/5); digitalWrite (led4, HIGH); Delay(del/5); digitalWrite (LED 3, alto); Delay(del/5); digitalWrite (led2, HIGH); Delay(del);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH);
Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, alto);
Delay(del/4);
digitalWrite (LED 3, bajo); digitalWrite (led4, HIGH);
Delay(del/4);
digitalWrite (led4, LOW); digitalWrite (led5, HIGH);
Delay(del/4);
digitalWrite (led5, LOW); digitalWrite (led6, HIGH);
Delay(del/4);
digitalWrite (led6, LOW); digitalWrite (led7, HIGH);
Delay(del/4);
digitalWrite (led7, LOW); digitalWrite (led8, HIGH);
Delay(del/4);
digitalWrite (led8, LOW); digitalWrite (led9, HIGH);
Delay(del/4);
digitalWrite (led9, LOW); digitalWrite (led10, HIGH);
Delay(del/4);
digitalWrite (led10, LOW); digitalWrite (led11, HIGH);
Delay(del/4);
digitalWrite (led11, LOW); digitalWrite (led12, HIGH);
Delay(del/4);
digitalWrite (led12, LOW); digitalWrite (led13, HIGH); Delay(del/4);
digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); Delay(del/5); digitalWrite (LED 3, alto); Delay(del/5); digitalWrite (led4, HIGH); Delay(del/5); digitalWrite (led5, HIGH); Delay(del/5); digitalWrite (led6, HIGH); Delay(del/5); digitalWrite (led7, HIGH); Delay(del/5); digitalWrite (led8, HIGH); Delay(del/5); digitalWrite (led9, HIGH); Delay(del/5); digitalWrite (led10, HIGH); Delay(del/5); digitalWrite (led11, HIGH); Delay(del/5); digitalWrite (led12, HIGH); Delay(del/5); digitalWrite (led13, HIGH); Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led13, HIGH); Delay(del/5); digitalWrite (led12, HIGH); Delay(del/5); digitalWrite (led11, HIGH); Delay(del/5); digitalWrite (led10, HIGH); Delay(del/5); digitalWrite (led9, HIGH); Delay(del/5); digitalWrite (led8, HIGH); Delay(del/5); digitalWrite (led7, HIGH); Delay(del/5); digitalWrite (led6, HIGH); Delay(del/5); digitalWrite (led5, HIGH); Delay(del/5); digitalWrite (led4, HIGH); Delay(del/5); digitalWrite (LED 3, alto); Delay(del/5); digitalWrite (led2, HIGH); Delay(del);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); digitalWrite (led6, HIGH); digitalWrite (led7, HIGH); digitalWrite (led8, HIGH); digitalWrite (led9, HIGH); digitalWrite (led10, HIGH); digitalWrite (led11, HIGH); digitalWrite (led12, HIGH); digitalWrite (led13, HIGH);
Delay(del/4); digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); digitalWrite (led6, HIGH); digitalWrite (led7, HIGH); digitalWrite (led8, HIGH); digitalWrite (led9, HIGH); digitalWrite (led10, HIGH); digitalWrite (led11, HIGH); digitalWrite (led12, HIGH); digitalWrite (led13, HIGH);
Delay(del/4); digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH);
Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, alto);
Delay(del/4);
digitalWrite (LED 3, bajo); digitalWrite (led4, HIGH);
Delay(del/4);
digitalWrite (led4, LOW); digitalWrite (led5, HIGH);
Delay(del/4);
digitalWrite (led5, LOW); digitalWrite (led6, HIGH);
Delay(del/4);
digitalWrite (led6, LOW); digitalWrite (led7, HIGH);
Delay(del/4);
digitalWrite (led7, LOW); digitalWrite (led8, HIGH);
Delay(del/4);
digitalWrite (led8, LOW); digitalWrite (led9, HIGH);
Delay(del/4);
digitalWrite (led9, LOW); digitalWrite (led10, HIGH);
Delay(del/4);
digitalWrite (led10, LOW); digitalWrite (led11, HIGH);
Delay(del/4);
digitalWrite (led11, LOW); digitalWrite (led12, HIGH);
Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, HIGH); Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4);
digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); Delay(del/4); digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); Delay(del/4); digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, HIGH); digitalWrite (led7, HIGH); Delay(del/4); digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, HIGH); digitalWrite (led9, HIGH); Delay(del/4);
digitalWrite (led2, HIGH); digitalWrite (LED 3, alto); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, HIGH); digitalWrite (led7, HIGH); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, HIGH); digitalWrite (led11, HIGH); Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, HIGH); digitalWrite (led5, HIGH); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, HIGH); digitalWrite (led9, HIGH); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, HIGH); digitalWrite (led13, HIGH); Delay(del/4);
digitalWrite (led2, LOW); digitalWrite (LED 3, bajo); digitalWrite (led4, LOW); digitalWrite (led5, LOW); digitalWrite (led6, LOW); digitalWrite (led7, LOW); digitalWrite (led8, LOW); digitalWrite (led9, LOW); digitalWrite (led10, LOW); digitalWrite (led11, LOW); digitalWrite (led12, LOW); digitalWrite (led13, bajo); Delay(del/4); }