Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*** constantes ***/
- #define POT1 A0
- #define POT2 A1
- #define TOTLED B // Total LEDs
- /*** Variables ***/
- int led[TOTLED] = {
- 2,3,4,5,6,7,8,9 } ;
- /***configuración***/
- void setup () {
- int pos= 0;
- while (pos < TOTLED){
- pinMode (led[pos], OUTPUT);
- pos=pos+1;
- }
- pinMode(POT1, INPUT);
- pinMode(POT2, INPUT);
- } // fin del setup()
- /*** Ciclo Principal ***/
- void loop() {
- //Sensores
- int t_encendido = analogRead(POT1);
- int t_apagado = analogRead(POT2);
- // Acciones
- for (int pos = 0; pos < TOTLED; pos ++){
- on (led[pos], t_enecendido);
- off (led[pos], t_apagado);
- }
- for (int pos = TOTLED-2; pos > 0 ; pos --){
- on (led[pos], t_enecendido);
- off (led[pos], t_apagado);
- }
- } // fin del loop()
- /*** funciones ***/
- // Pone en +5V el pin indicado, durante algunos milisegundos
- void on (int pin, int mas){
- digitalWrite(pin, HIGH);
- delay(ms);
- }// fin del void on()
- // Pone en GND el pin indicado, durante algunos milisegundos
- void off (int pin, int mas){
- digitalWrite(pin, LOW);
- delay(ms);
- }// fin del void off()
- /*** fin ***/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement