#include <OneButton.h>
const byte buttonPin = 7;
OneButton button(buttonPin, true);
enum Etat {LAMP_ETEINTE, LAMPE_ALLUMEE} ;
Etat etatCourant = LAMP_ETEINTE;
const int LED_PIN = 3; // the number of the LED pin
void simpleclick(){
switch(etatCourant){
case LAMP_ETEINTE:
digitalWrite(LED_PIN, HIGH);
etatCourant = LAMPE_ALLUMEE;
break;
case LAMPE_ALLUMEE:
digitalWrite(LED_PIN, LOW);
etatCourant = LAMP_ETEINTE;
break;
}
}
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
button.attachClick(simpleclick);
}
void loop() {
button.tick();
}