Advertisement
Guest User

Exercice 1

a guest
Apr 21st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # P-11
  2. # Royal - Erve
  3.  
  4. //Declaration de nos variables
  5. const int buttonPin = 2;
  6. const int ledPin = 12;
  7. int buttonState = 0;
  8.  
  9. //Notre setup pour initialiser nos Pin
  10. void setup() {
  11.     pinMode(ledPin, OUTPUT);
  12.     pinMode(buttonPin, INPUT);
  13. }
  14.  
  15. //Notre main qui bouclera à l'infini
  16. void loop(){
  17.     buttonState = digitalRead(buttonPin); //On recupere l'état du button
  18.  
  19.     if(buttonState == HIGH) //On verifie si le button vaut 1
  20.     {
  21.         digitalWrite(ledPin, HIGH); //On allume la led
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement