How to run a stepper motor 360 degree clockwise & counter clockwise direction.

I am using 28byj-48 stepper motor & ULN2003 motor driver. I want to make move 360 degree clockwise & counter clockwise direction. I only can run the motor 360 degree counter clockwise direction. Can anyone help me to run a stepper motor 360 degree clockwise & counter clockwise direction continuously?

You need to post your code
And please use the code button </> so your code looks like this and is easy to copy to a text editor

Are you using the Stepper library?

...R
Stepper Motor Basics

I use this code.But can not reverse the motor .

#include <Stepper.h>

int in1Pin = 8;
int in2Pin = 9;
int in3Pin = 10;
int in4Pin = 11;

Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);

void setup()
{
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(in3Pin, OUTPUT);
pinMode(in4Pin, OUTPUT);

motor.setSpeed(25);
}

void loop()
{
int steps = 360;
motor.step(steps);
delay(100);

steps = -360;
motor.step(steps);
delay(500); //Semicolon added
}

It seems illogical to name the variable in1pin and then set it as an OUTPUT

That sort of thing does not matter much in a short program but it can make a longer program very difficult to maintain.

Are you saying that the motor moves 360 steps in the forward direction but then does not move 360 steps in the other direction? Does it move at all in the reverse direction?

If so, I wonder is your wiring correct?

Try a much longer delay() between directions - perhaps 5 seconds.

...R

Robin2:
It seems illogical to name the variable in1pin and then set it as an OUTPUT

I think I know why Tanbir has done this.

He has most likely got a driver board like this one:

And has used variable names based on the names of the pins as shown on the PCB legend.

You have to pass the pins in the right order to Stepper.begin () - so check that libraries
documentation and check the widings of the motor with a multimeter. There are 24 ways to
order 4 wires and only 8 will be workable...

to run backwards, simply reverse one of the coils..
ie swap the pins

in1pin = 9 instead of 8
in2pin = 8 instead of 9

regards

allan.