Advertisement
octo_cat

Untitled

Jun 11th, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. const int buttonPin = 2;
  2. const int ledPin2 = 4;
  3. int count = 0;
  4. bool lastButtonState;
  5. int buttonState = 0;
  6. void setup() {
  7. pinMode(ledPin2, OUTPUT);
  8. pinMode(buttonPin, INPUT);
  9. }
  10.  
  11. void loop() {
  12. buttonState = digitalRead(buttonPin);
  13. if (buttonState == HIGH && lastButtonState == LOW) {
  14. lastButtonState = buttonState;
  15. count++;
  16. }
  17. else {
  18. lastButtonState = buttonState;
  19. digitalWrite(ledPin2, LOW); }
  20. if (count >= 4) {
  21. count = 0; }
  22.  
  23. if (count == 1) {
  24. digitalWrite(ledPin2, LOW); }
  25. else {
  26. digitalWrite(ledPin2, LOW);}
  27.  
  28. if (count == 2) {
  29. digitalWrite(ledPin2,HIGH);
  30. delay(1000);
  31. digitalWrite(ledPin2,LOW); }
  32. else {
  33. digitalWrite(ledPin2, LOW);
  34. }
  35. if (count == 3) {
  36. digitalWrite(ledPin2, HIGH); }
  37. else {
  38. digitalWrite(ledPin2, LOW);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement