Created
October 3, 2019 15:45
-
-
Save parzibyte/b47ca299b32016a614f940a6b9949876 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Escribir los números del 0 al 255 en su representación binaria usando leds | |
@autor parzibyte | |
@web parzibyte.me | |
*/ | |
#define PIN_CLOCK 2 | |
#define PIN_LATCH 3 | |
#define PIN_DATA 4 | |
void setup() { | |
/* | |
Al final de todo, son pines de salida, | |
y debemos establecerlos como tal | |
*/ | |
pinMode(PIN_CLOCK, OUTPUT); | |
pinMode(PIN_LATCH, OUTPUT); | |
pinMode(PIN_DATA, OUTPUT); | |
} | |
void loop() { | |
/* | |
Vamos a hacer lo mismo pero ahora en un ciclo, y dentro de loop, para que cuando llegue a 255 inicie de nuevo | |
*/ | |
for (int m = 0; m < 256; m++) { | |
digitalWrite(PIN_LATCH, LOW); //Le decimos que vamos a escribir algo... | |
shiftOut(PIN_DATA, PIN_CLOCK, LSBFIRST, m); //Escribimos el número en el que ahora está el ciclo | |
digitalWrite(PIN_LATCH, HIGH) ; //Y le indicamos que lo guarde | |
delay(500); //Esperamos un poco (medio segundo), para que se vea la animación. De otro modo, no veríamos correctamente cómo va "contando" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment