ivanmih99
Published

Obstacle Avoidance Stepper

When sensor detects movement the stepper motor activates. Can be reversed by removing the ! in if cycle.

IntermediateFull instructions provided1,939
Obstacle Avoidance Stepper

Things used in this project

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic

Schematic view of the project.

Breadboard

Breadboard view of the project.

Code

Code for Obstalce avoidance stepper

C#
Can be reversed by deleting the ! in the if cycle.
void setup() {
   Serial.begin(9600);
  pinMode(3, INPUT); //IR Sensor
  pinMode(8, OUTPUT); // Stepper Direction
  pinMode(9, OUTPUT); // Stepper Step
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
}

void loop() {
int detect = digitalRead (3);
if (detect != HIGH){
    digitalWrite(9, HIGH);
  delayMicroseconds(500);          
  digitalWrite(9, LOW); 
  delayMicroseconds(500);  
}
else{
  if(detect == LOW)
  digitalWrite(9, LOW);
  delayMicroseconds(500);          
  digitalWrite(9, HIGH); 
  delayMicroseconds(500); 
}
}

Credits

ivanmih99

ivanmih99

1 project • 0 followers

Comments