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