safwan092

Untitled

Nov 14th, 2022
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1.  
  2. int State = LOW;
  3. long previousMillis = 0;
  4.  
  5. long interval = 1000;
  6. long totalTime = 60000;
  7.  
  8. void setup() {
  9.  
  10. }
  11.  
  12.  
  13. void loop() {
  14.  
  15. unsigned long currentMillis = millis();
  16. //***************************************************
  17. // start of TotalTime
  18. if (currentMillis < totalTime) {
  19. if (currentMillis - previousMillis > interval) {
  20. previousMillis = currentMillis;
  21. if (State == LOW) {
  22. State = HIGH;
  23. //front
  24. }
  25. else {
  26. State = LOW;
  27. //back
  28. }
  29. }
  30. }//end of TotalTime
  31. //***************************************************
  32. else{
  33. //stop
  34. }
  35. }// end of loop
Advertisement
Add Comment
Please, Sign In to add comment