CCCPaste

935b0f2eddfb9

#define PIN_BOTON  8
#define CONFIGURAR_BOTON pinMode(PIN_BOTON, INPUT)
#define BOTON_PRESIONADO (digitalRead(PIN_BOTON)==HIGH)

#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_BOTON;
  CONFIGURAR_LED;
  ENCENDER_LED;
  }

bool SePresionoBoton(void)
  {
  static bool boton_presionado_ant=false;

  if(BOTON_PRESIONADO == boton_presionado_ant) return(false);
  boton_presionado_ant=BOTON_PRESIONADO;

  return(BOTON_PRESIONADO);
  }
 
void loop()
  {
    unsigned long tiempo = 0;
if (SePresionoBoton()){
   if (millis - tiempo > 50){
      tiempo = millis();
   }
}
if(SePresionoBoton())  //Si se presionĂ³ el boton
    ENCENDER_LED;
    delay(5000); //esperamos 5 segundo
  }