How to only revolve the stepper motor for one rotation?

Below is my code and wiring. I am able to rotate my stepper motor constantly in either direction. What I want to do in my code is - just turn it one rotation clockwise and then one rotation counter clock wise. That's it.

void setup() {
  
  pinMode(2, OUTPUT); //pin 2 is for direction
  pinMode(3, OUTPUT); //pin3 is control signal
  
}

void loop() {
 
  digitalWrite(3, HIGH);
  digitalWrite(3, LOW);
  delayMicroseconds(100);

}

Count steps, and stop when one revolution has been achieved. The number of steps depends on the motor.

The search phrase "arduino stepper motor" turns up countless tutorials.

Hi,
How many degrees per step does your servo motor turn?

The motor driver switches are usually set for the number of steps/rotation...

Here is mine on my laser ...

Read off the placard what values it's set ...

So mine is set for 2000 steps/rotation...


If this is a diy, you will have to determine the the step angle of the motor, 1.8॰ or 0.9॰ ... the steps/rotation of one will be twice that of the other... There is lower available torque with a smaller step rate...


This also controls current to the drive motor... Ensure it's set properly for your motor.

Good luck

:smiley_cat:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.