[nano] Programmer une action momentanée sur un contact fermé longtemps
Bonjour tout le monde connait l'exemple du bouton poussoir sur Arduino. (ci-dessous) le problème est que c'est un contact au lieu d'un bouton poussoir et qu'il reste fermé longtemps (10 minutes) or j'aimerai que la led ne s'allume que 3 ou 4 seconde même si le contact reste fermé et puis s'éteigne. Mais si le contact s'ouvre et se ferme 15 minute après j'ai à nouveau la led qui s'allume 3 à 4 seconde et puis s’éteint. Quelqu'un pourrait m'aider pour solutionner ce problème? Merci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
} |
Merci j'ai suivi votre conseil et c'est résolu merci
Merci j'ai suivi votre conseil et c'est résolu merci :D:applo: