Je viens de terminer cela fonctionne.
Merci pour votre aide.
const int buttonPin = 4; // the number of the pushbutton pin
const int ledPin1 = 3; // the number of the LED pin
const int ledPin2 = 2;
// Variables will change:
int ledState1 = LOW; // the current state of the output pin
int ledState2 = LOW; // the current state of the output pin
int buttonState; // the current reading from the input pin
int fonctionnement;
int lastButtonState = LOW; // the previous reading from the input pin
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long lastactiontime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers
long limitDelay = 1500; // the time limit
int buttonPushCounter = 0;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
fonctionnement==0;
digitalWrite(ledPin1, ledState1);
digitalWrite(ledPin2, ledState2);
}
void loop() {
int reading = digitalRead(buttonPin);
//_________________________________________________________
if (reading != lastButtonState) {
lastDebounceTime = millis();
if (buttonPushCounter == 0) {
lastactiontime = millis();
}
if (buttonPushCounter != 0) {
if ((millis() - lastactiontime) > limitDelay ) {
buttonPushCounter=0;
}
}
}
//________________________________________________________
if ((millis() - lastDebounceTime) > debounceDelay ) {
if (reading != buttonState) {
buttonState = reading;
if (buttonState == HIGH) {
buttonPushCounter++;
//________________________________________________________
if (fonctionnement==1) {
ledState1 = !ledState1;
digitalWrite(ledPin1, ledState1); //moteur
//ledPin2 inchangé
buttonPushCounter=0;
}
//________________________________________________________
if (fonctionnement==0) {
if (buttonPushCounter >= 3 ) {
ledState1 = !ledState1;
ledState2 = !ledState2;
fonctionnement=1;
digitalWrite(ledPin1, ledState1); //moteur
delay(3000);
digitalWrite(ledPin2, ledState2); //aspi
buttonPushCounter=0;
}
}
//________________________________________________________
}
}
}
lastButtonState = reading;
}