Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Stepper.h>
- int isObstaclePin = 7;
- const int stepsPerRevolution = 7600;
- int isObstacle = HIGH;
- Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
- void setup() {
- myStepper.setSpeed(60);
- pinMode(isObstaclePin, INPUT);
- Serial.begin(9600);
- }
- void loop()
- {
- isObstacle = digitalRead(isObstaclePin);
- if (isObstacle == LOW){
- Serial.println("OBSTACLE!!, OBSTACLE!!");
- myStepper.step(stepsPerRevolution);
- }
- else {
- Serial.println("clear");
- myStepper.step(-stepsPerRevolution);
- }
- delay(200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement