Small stepper motors

For my clock project I needed to control the position of the hands. My options were continuously rotating servos or stepper motors.

I found some small 28BYJ-48 stepper motors and gearbox with ULN2003 driver boards on the internet so I decided to go for that option.

I misread the details and thought I was getting a controller chip rather than a driver. The distinction is important, a driver just provides power but a controller simplifies driving the motor so rather than needing to drive the individual coils of the motor you just need direction and step controls. I investigated and the controller functionality can be handled in software on the Arduino.

I intitally tried the Arduino stepper library which on first apperances worked well. However when I ran it for a second time to check that the gears were centred on the spindles, I noticed that the motors were always turning in one direction. I wrote a little test program to sequence the LEDs on the driver board which would check my wiring was ok. It was. I tried this sequence with the motors and they turned correctly. I expanded the program slightly and ran the motor forward and then successfully in reverse.

  • //LED test
  • void setup() {
  • // initialize the digital pins as an output.
  • pinMode(8, OUTPUT);
  • pinMode(9, OUTPUT);
  • pinMode(10, OUTPUT);
  • pinMode(11, OUTPUT);
  • }
  • // the loop routine runs over and over again forever:
  • void loop() {
  • //Anticlockwise 8,9,10,11
  • //Clockwise 11,10,11,10
  • digitalWrite(11, HIGH);
  • delay(10);
  • digitalWrite(8, LOW);
  • delay(10);
  • digitalWrite(10, HIGH);
  • delay(10);
  • digitalWrite(11, LOW);
  • delay(10);
  • digitalWrite(9, HIGH);
  • delay(10);
  • digitalWrite(10, LOW);
  • delay(10);
  • digitalWrite(8, HIGH);
  • delay(10);
  • digitalWrite(9, LOW);
  • delay(10);
  • }

Yuan Liu @LiuYuanster mentioned on twitter that the default Arduino Stepper library only works with cross-wire pin sequence e.g. 8,10,9,11 and sent me the following link for information about “Small Steppers“. I tried the cross wired approach and that worked just fine with the motors turning in both directions.

The small steppers article had a link to AccelStepper which appears to have all of the features I need. It already has a “setposition” which I’ll need when I wire up the optical sensor to detect the home position.

I found another potential library via the Arduino playground called “CustomStepper“. This library works in a similar manner to the AccelStepper but has less features, I may need to switch to this if I run into memory issues with the AccelStepper library or even cut into that.

For the moment, I’m happy that I can make the motor turn so will move onto making a homing sensor for it.

BYJ-48 Stepper Motor and ULN2003 Driver - Little British Robot Company Affiliate Scheme

Leave a Reply

Your email address will not be published. Required fields are marked *

 characters available