Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. const int switchPin = 8;
  2. unsigned long previousTime = 0;
  3. int switchState = 0;
  4. int prevSwitchState = 0;
  5. int led = 2;
  6. long interval = 1000;
  7. void setup() {
  8. for(int x = 2;x<8;x++){
  9. pinMode(x, OUTPUT);
  10. }
  11. pinMode(switchPin, INPUT);
  12. }
  13. void loop(){
  14. unsigned long currentTime = millis();
  15. if(currentTime -previousTime > interval) {
  16. previousTime = currentTime;
  17. digitalWrite(led, HIGH);
  18. led++;
  19. if(led == 7){
  20. }
  21. }
  22. switchState = digitalRead(switchPin);
  23. if(switchState != prevSwitchState){
  24. for(int x = 2;x<8;x++){
  25. digitalWrite(x, LOW);
  26. }
  27. led = 2;
  28. previousTime = currentTime;
  29. }
  30. prevSwitchState = switchState;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement