//Ejemplo del Blink Multidestello
//12/05/20
////https://pastebin.com/EUeWirzt
#define PIN_LED 13
#define CONFIGURAR_LED pinMode(PIN_LED, OUTPUT)
#define ENCENDER_LED digitalWrite(PIN_LED, HIGH)
#define APAGAR_LED digitalWrite(PIN_LED, LOW)
void setup()
{
CONFIGURAR_LED;
APAGAR_LED;
}
void BlinkMultidestello(void)
{
const unsigned char c_pulsos=3;
const unsigned int t_pulso=200;
const unsigned int t_pausa=1000;
static bool led_encendido=0;
static unsigned long millis_ant=0;
static unsigned long tpo_espera=0;
static unsigned char pulsos_restantes=0;
if(millis() - millis_ant < tpo_espera) return;
millis_ant=millis();
if(led_encendido)
{
pulsos_restantes--;
if(pulsos_restantes) tpo_espera=t_pulso;
else tpo_espera=t_pausa;
}
else
{
if(!pulsos_restantes)
{
pulsos_restantes= c_pulsos;
}
tpo_espera=t_pulso;
}
led_encendido = !led_encendido;
if(led_encendido) ENCENDER_LED;
else APAGAR_LED;
}
void loop()
{
BlinkMultidestello();
}