Advertisement
2607

button3

Jul 18th, 2019
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int Pin =8;
  2. int ledPin = 13;
  3. boolean lastButton = LOW;
  4. boolean ledOn = false;
  5.  
  6. void setup()
  7. {
  8.   pinMode(Pin, INPUT);
  9.   pinMode(ledPin, OUTPUT);
  10. }
  11.  
  12. void loop()
  13. {
  14.   if (digitalRead(Pin) == HIGH && lastButton == LOW)
  15.   {
  16.     ledOn = !ledOn;
  17.     delay(2000);
  18.     lastButton - HIGH;
  19.   }
  20.   else
  21.   {
  22.     lastButton = digitalRead(Pin);
  23.   }
  24.   digitalWrite(ledPin, ledOn);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement