Stepper motor not working with stepper library

Hey people,
Some time ago, I got an old broken fax from a friend of mine. Since it was broken, I went opening it and getting the parts that interested me the most. That time I didn’t even know what stepper motors were, and I was asking myself why in the world there would be motors with more than two or three wires. After I acknowledged that there were indeed two stepper motors in it, I’ve already thrown away the majority of the PCB’s which could’ve included a driver. Then, I bought an ULN2003A, and searched the web on how to control this stuff with my UNO. Now, I’m working on how to use the mitsumi M42SP-5P motor with the Stepper.h lib. I searched the web to find some code to control it roughly without the library, and If found one that worked in this site: Stepper Motor 5V 4-Phase 5-Wire & ULN2003 Driver Board for Arduino - Geeetech Wiki . The motor was actually supposed to get a bipolar driving, but it has five wires with one common, and it worked with a unipolar motor code.
I made really minor changes to adapt it to my motor:

int Pin0 = 11; //Pins 10 and 11 are one coil
int Pin1 = 10; 
int Pin2 = 9; //Pins 8 and 9 are another coil, and are the first to be turned HIGH
int Pin3 = 8; 
int _step = 0; 
boolean dir = true;// gre
void setup() 
{ 
 pinMode(Pin0, OUTPUT);  
 pinMode(Pin1, OUTPUT);  
 pinMode(Pin2, OUTPUT);  
 pinMode(Pin3, OUTPUT);  
} 
 void loop() 
{ 
 switch(_step){ 
   case 0: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, HIGH); 
   break;  
   case 1: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, HIGH); 
   break;  
   case 2: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, LOW); 
   break;  
   case 3: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, HIGH); 
     digitalWrite(Pin2, HIGH); 
     digitalWrite(Pin3, LOW); 
   break;  
   case 4: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, HIGH); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
   break;  
   case 5: 
     digitalWrite(Pin0, HIGH);  
     digitalWrite(Pin1, HIGH); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
   break;  
     case 6: 
     digitalWrite(Pin0, HIGH);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
   break;  
   case 7: 
     digitalWrite(Pin0, HIGH);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, HIGH); 
   break;  
   default: 
     digitalWrite(Pin0, LOW);  
     digitalWrite(Pin1, LOW); 
     digitalWrite(Pin2, LOW); 
     digitalWrite(Pin3, LOW); 
   break;  
 } 
 if(dir){ 
   _step++; 
 }else{ 
   _step--; 
 } 
 if(_step>7){ 
   _step=0; 
 } 
 if(_step<0){ 
   _step=7; 
 } 
 delay(15); //When the delay was 1, the motor wouldn't move
}
//

Thus, the motor with this code made flawlessly 360. Now, to the actual problem, when I try to control it using the stepper lib in the same hardware configuration as shown in the site’s image, it trembles and rarely does a circular movement. I used the example code from the stepper tutorial in the learning section, and the motor doesn’t work. I thought, maybe the order the pins are passed as arguments to the Stepper(steps, pin1, pin2, pin3, pin4) may be the problem? Do someone have an Idea of what’s going on?
Thanks.

The coils on the motor have to be energized in the proper sequence or the motor won't work. You can try swapping motor wire connections or pin numbers until it works, or you can set the software to step very very slowly and then check the output sequence using a multimeter. From those measurements you should be able to deduce the proper arrangement.

Thanks for the fast reply!
Yes, in the code I posted the arrangement and changes I made were exactly because of the coil sequence.

you can set the software to step very very slowly and then check the output sequence using a multimeter

Excellent, simple solution. I'll try that and post the result after.
Thanks.

gabrielw6:
Thanks for the fast reply!
Yes, in the code I posted the arrangement and changes I made were exactly because of the coil sequence.

you can set the software to step very very slowly and then check the output sequence using a multimeter

Excellent, simple solution. I'll try that and post the result after.
Thanks.

Or even 4 LEDs + resistors...

Hey again
When you suggested that, I just wanted to code to see. But, this would involve modifying the library to stop on the HIGH outputs. Therefore, I just found easier to look up the library code itself. Thus, I figured out the pinout: it alternates the pins from each coil. For example, if we have coil 1 and coil 2, and Arduino pins (8, 9, 10, 11), in pin 8 we'd put one wire from coil 1, after in pin 9 we'd put the pin from coil 2, etc.
(8, 9, 10, 11)
^ ^ ^ ^
| | | |
1 2 1 2
Anyway, thanks for your reply! :slight_smile: