Running a Stepper Motor - Please help, very urgent

Hello,

I want to use a stepper motor for solar tracking application. First, I intended to test the Servo and the Arduino UNO board with a sample code that comes with the software. The code is as follows:

#include <Stepper.h>

const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 8,9,10,11);

int stepCount = 0;

void setup() {
Serial.begin(9600);
}

void loop() {
myStepper.step(1);
Serial.print("steps:" );
Serial.println(stepCount);
stepCount++;
delay(500);
}

But when I connect the pins {8,9,10,11} to the unipolar stepper through the driver ULN2004 (12V supply through an adapter), the motor takes two small rotations in one direction and a big rotation in another -bringing it back to the initial position.

What should I do to rectify this ?

Thanks in advance !

What motor are you using?
Show a schematic of the circuit as it is wired?
Make sure the wires are connected properly to the drivers.

If you fail to sequence the 4 windings correctly it will do odd things - change your delay to several seconds and watch the rotation
carefully - if its not stepping equal amount per change then you have the sequence wrong. There are 24 ways to connect 4 wires and only 8 of those will step correctly (4 for each direction).

Never disconnect a winding while the motor is powered up, BTW, you can blow the driver.

There are 24 ways to connect 4 wires and only 8 of those will step correctly (4 for each direction).

You can eliminate most of the guesswork with an ohmeter to map out the winding arrangement.

Not if its a 5-wire motor.

I am using a very small stepper motor (just to test the code)
This is the circuit I am using : http://arduino.cc/en/Reference/StepperUnipolarCircuit
(The 4-pin connection)
and I am pretty sure that the connections to my motor is correct !

My motor has 5 pins : One for power, the rest for the sequence.

kvsrinie:
and I am pretty sure that the connections to my motor is correct !

If that were true it would work...

[a thought: you have measured the winding resistances to check the motor's undamaged?]

kvsrinie:
the motor takes two small rotations in one direction and a big rotation in another -bringing it back to the initial position.

What should I do to rectify this ?

Thanks in advance !

Usually swapping 2 of the stepper wires (that go to the ULN2004) gets the order of stepping correct.

You seem to have a problem like mine. I think the problem is with the stepper.h class. The stepper class is said to be made for driving both unipolar (5 wires) and bipolar (4,6,8 wire) motors and it seems to me it can run only bipolar motors. The problem is in the sequence needed to run those motors. Sequence for unipolar motors needs to be 1,0,0,0 ; 0,1,0,0 ; 0,0,1,0 ; 0,0,0,1 and bipolar motors use a different sequence. For a test, forget the stepper class and just try sending those sequences right to the 6,7,8,9 pins, or whatever your pins are, ofc you need to follow every step with a delay... I think you can find some example on driving a stepper without the stepper class somewhere on the Arduino site. Tell if it helps