document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #define POT1 A0
  2. #define POT2 A1
  3. #define TOTLED 8 // Total LEDs
  4.  
  5. /********** Objetos **********/
  6.  
  7. // ninguno
  8.  
  9. /********** Variables **********/
  10.  
  11. int led[TOTLED] = {
  12.  
  13. 2, 3, 4, 5, 6, 7, 8, 9};
  14.  
  15. /********** Configuracion **********/
  16.  
  17. void setup() {
  18. int pos=0;
  19. while (pos < TOTLED){
  20. pinMode(led[pos], OUTPUT);
  21. pos=pos+1;
  22. }
  23. pinMode(POT1, INPUT);
  24. pinMode(POT2, INPUT);
  25. } // end setup()
  26.  
  27. /********** Ciclo Principal **********/
  28.  
  29. void loop() {
  30.  
  31. // Sensores
  32. int t_encendido = analogRead(POT1);
  33. int t_apagado = analogRead(POT2);
  34.  
  35. // Acciones
  36. for (int pos = 0; pos < TOTLED; pos++) {
  37. on(led[pos], t_encendido);
  38. off(led[pos], t_apagado);
  39. }
  40. for (int pos = TOTLED-2; pos > 0; pos--) {
  41. on(led[pos], t_encendido);
  42.  
  43. off(led[pos], t_apagado);
  44. }
  45.  
  46. } // end loop()
  47.  
  48. /********** Funciones **********/
  49.  
  50. // Pone en +5V el pin indicado, durante tantos milisegundos
  51. void on(int pin, int ms){
  52. digitalWrite(pin, HIGH);
  53. delay(ms);
  54. } // end on()
  55.  
  56. // Pone en GND el pin indicado, durante tantos milisegundos
  57. void off(int pin, int ms){
  58. digitalWrite(pin, LOW);
  59. delay(ms);
  60. } // end off()
  61.  
  62. /********** Fin ***********/
');