Étape 2: Codage : après avoir téléchargé l’esquisse, appuyez sur le bouton et le voyant sera sur. Si elle est libérée, LED se fermera.
//Push Buttonconst int buttonPin = 2; //The Button Pin const int ledPin = 13; //The LED Pin int buttonState = 0; //To store the state of the button void setup() { pinMode(ledPin, OUTPUT); //Set the LED Pin to be output pinMode(buttonPin, INPUT); //Set the button Pin to be input } void loop(){ buttonState = digitalRead(buttonPin); //read the state of the button // If the button is pressed, the button state will be HIGH if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); // If button state is HIGH, then turn on LED } else { digitalWrite(ledPin, LOW); // If button state is LOW, then turn off LED } }