Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PIN_LED1 0
- #define PIN_LED2 1
- #define PIN_LED3 2
- #define PIN_LED4 3
- #define PIN_LED5 4
- #define PIN_LED6 5
- #define CANT_LEDS 6
- const int pin_led[]={PIN_LED1, PIN_LED2, PIN_LED3, PIN_LED4, PIN_LED5, PIN_LED6};
- #define CONFIG_LED(x) pinMode(pin_led[x], OUTPUT)
- #define LED_ON(x) digitalWrite(pin_led[x], HIGH)
- #define LED_OFF(x) digitalWrite(pin_led[x], LOW)
- #define MS_ESPERA 100
- void setup() {
- for(int i=0; i<CANT_LEDS; i++) CONFIG_LED(i);
- }
- void loop() {
- Barra();
- }
- void Barra(void)
- {
- static unsigned long millis_ant=0;
- static int i=0;
- //Evento sincrónico
- if(millis() - millis_ant < MS_ESPERA) return;
- millis_ant=millis();
- if(i>= (2*CANT_LEDS)) i=0;
- if(i<CANT_LEDS) LED_ON(i);
- else LED_OFF(2*CANT_LEDS-i-1);
- i++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement