Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. const int MAXLED = 3;
  2. // arreglo de 8 LEDs, desde el pin 0 hasta el pin 5
  3. //Pin connected to latch pin (ST_CP) of 74HC595
  4. const int latchPin = 10;
  5. //Pin connected to clock pin (SH_CP) of 74HC595
  6. const int clockPin = 11;
  7. ////Pin connected to Data in (DS) of 74HC595
  8. const int dataPin = 9;
  9.  
  10. int led[MAXLED] = {9,10,11};
  11. int dato[10]={63,6,91,79,102,109,94,7,127,103};
  12.  
  13. // se ejecuta 1 sola vez, al iniciar el programa
  14. void setup() {
  15.  
  16.   for (int i=0; i<MAXLED; i++)
  17.     pinMode(led[i], OUTPUT);
  18. }
  19.  
  20. // se repite infinitamente mientras el arduino tenga corriente
  21. void loop()
  22. {
  23.   int a = analogRead(A0);
  24.   a = map(a, 0, 1023, 0,10);
  25.   digitalWrite(latchPin, LOW);
  26.   shiftOut(dataPin, clockPin, MSBFIRST,dato[a] );
  27.   digitalWrite(latchPin, HIGH);
  28. }