You are on page 1of 1

// Définition des broches

const int boutonPin = 2; // Broche du bouton-poussoir


const int ledPin = 13; // Broche de la LED

// Variable pour stocker l'état du bouton


int etatBouton = 0;

void setup() {
// Initialiser la broche du bouton en tant qu'entrée
pinMode(boutonPin, INPUT);

// Initialiser la broche de la LED en tant que sortie


pinMode(ledPin, OUTPUT);
}

void loop() {
// Lire l'état du bouton (HIGH ou LOW)
etatBouton = digitalRead(boutonPin);

// Si le bouton est enfoncé (HIGH), allumer la LED


if (etatBouton == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
// Sinon, éteindre la LED
digitalWrite(ledPin, LOW);
}
}

You might also like