Advertisement
hidromotic

Blink Simétrico No BLoqueante

Apr 11th, 2024
788
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | Software | 0 0
  1. //BlinkSimétrico No bloqueante: Un led que destella,
  2. //donde el tiempo de encendido es el mismo que el de apagado.
  3. #define PIN_LED 13
  4. #define CONFIG_LED      pinMode(PIN_LED, OUTPUT)
  5. #define AJUSTAR_LED(x)  digitalWrite(PIN_LED, x)
  6. #define MS_ESPERA 50
  7.  
  8. void setup() {
  9.   // put your setup code here, to run once:
  10.   CONFIG_LED;
  11.   }
  12.  
  13. void loop()
  14.   {
  15.   BlinkSimetrico();
  16.   }
  17.  
  18. void BlinkSimetrico(void)
  19.   {
  20.   static unsigned long millis_ant=0;
  21.   static bool estado_led=0;
  22.  
  23.   if(millis() - millis_ant < MS_ESPERA) return;
  24.   millis_ant=millis();  
  25.  
  26.   estado_led= !estado_led;
  27.  
  28.   AJUSTAR_LED(estado_led);
  29.   }
Tags: Arduino
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement