Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <Stepper.h>
  2.  
  3. int isObstaclePin = 7;
  4. const int stepsPerRevolution = 7600;
  5. int isObstacle = HIGH;
  6. Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
  7.  
  8. void setup() {
  9. myStepper.setSpeed(60);
  10. pinMode(isObstaclePin, INPUT);
  11. Serial.begin(9600);
  12. }
  13.  
  14. void loop()
  15. {
  16. isObstacle = digitalRead(isObstaclePin);
  17. if (isObstacle == LOW){
  18. Serial.println("OBSTACLE!!, OBSTACLE!!");
  19. myStepper.step(stepsPerRevolution);
  20. }
  21. else {
  22. Serial.println("clear");
  23. myStepper.step(-stepsPerRevolution);
  24. }
  25. delay(200);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement