MrDj200

Button#+

Dec 21st, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. const int buttonPin = 2;
  2. const int ledPin =  13;
  3.  
  4. int buttonState = 0;
  5.  
  6. void setup() {
  7.   pinMode(ledPin, OUTPUT);
  8.   pinMode(buttonPin, INPUT);
  9. }
  10.  
  11. void loop() {
  12.   buttonState = digitalRead(buttonPin);
  13.   delay(500);
  14.   if (buttonState == HIGH) {
  15.     digitalWrite(ledPin, HIGH);
  16.   } else {
  17.     digitalWrite(ledPin, LOW);
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment