Advertisement
2607

button2

Jul 18th, 2019
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  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. lastButton - HIGH;
  18. }
  19. else
  20. {
  21. lastButton = digitalRead(Pin);
  22. }
  23. digitalWrite(ledPin, ledOn);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement