hidromotic

Blink Básico

Mar 19th, 2026
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | Software | 0 0
  1. //Blink
  2. //Led que se enciende, espera cierto tiempo, se apaga, espera otro tiempo y vuelve a repetir el ciclo
  3. #define PIN_LED           14
  4. #define CFG_LED           pinMode(PIN_LED, OUTPUT)
  5. #define ENCENDER_LED      digitalWrite(PIN_LED, HIGH)
  6. #define APAGAR_LED        digitalWrite(PIN_LED, LOW)
  7.  
  8. #define PIN_BOTON         9
  9. #define CFG_BOTON         pinMode(PIN_BOTON, INPUT)
  10. #define BOTON_PRESIONADO  digitalRead(PIN_BOTON)
  11.  
  12. void setup()
  13.   {
  14.   // put your setup code here, to run once:
  15.   CFG_LED;
  16.   CFG_BOTON;
  17.   APAGAR_LED;
  18.   }
  19.  
  20. void loop() {
  21.   // put your main code here, to run repeatedly:
  22.   if(BOTON_PRESIONADO) Blink();
  23.   }
  24.  
  25. void Blink(void)
  26.   {
  27.   ENCENDER_LED;
  28.  
  29.   //ESPERAR_TIEMPO_ENCENDIDO
  30.   delay(100);
  31.   APAGAR_LED;
  32.  
  33.   //ESPERAR_TIEMPO_APAGADO
  34.   delay(900);
  35.   }
Advertisement
Add Comment
Please, Sign In to add comment