#define buttonPin 27 #define led1 1 #define led2 26 #define led3 0 int compte = 0; int buttonState = 0; int buffer = 0; void setup() { pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { buttonState = digitalRead(buttonPin); //see the state of the button Serial.println(compte); if(buttonState == 1) // if the button is engage buffer = 1; if(buttonState == 0 && buffer == 1){ //if we relese the button (we increment only here) compte ++; buffer = 0; } if(compte >2) //switch between the 3 LEDs compte=0; if(compte == 0){ //Turn on and off each LED digitalWrite(led1, HIGH); digitalWrite(led3, LOW); } else if(compte == 1){ digitalWrite(led2, HIGH); digitalWrite(led1, LOW); } else{ digitalWrite(led3, HIGH); digitalWrite(led2, LOW); } }