Using Stepper Motors

Stepper Motors

WARNING: NO MOTOR SHOULD EVER BE CONNECTED DIRECTLY TO A RASPBERRY PI

However, if you would like to build a neat little vehicular robot then you can do so by connecting up a pair of cheap Stepper Motors through a couple of very cheap ULN2003s.

The cheap 5V steppers that are widely available (BY28) don’t turn very fast (maximum about 12 RPM) which actually makes them idea as beginners motors as your vehicle won’t run away during testing 🙂

These motors have 5 connections, 1 for power and the rest to control the stepping. (Their technical name is 5 Wire Unipolar Stepper Motor)

To use them in Scratch, you need to connect them up as follows

StepperA should end up (via the ULN2003 buffer of course) being controlled by physical pins 11,12,13 and 15 – Stepper B is via pins 16,18,22 and 7.

Pin 9 of the ULN2003s should be connected to +ve on the motor battery pack.

(The battery +ve MUST NOT be connected to any pins on the Pi)

stepperIn your Scratch program, you need to say that you are using Stepper motors instead of ordinary motors this is simply done by broadcasting Stepper in your Green Flag code block.

You can then simply using variables MotorA and MotorB as before with simple DC motors but this time they will each control 4 pins at a time.

sma-100

The advantage of using stepper motors is that they can be just as easily stepped backwards as forwards. So to make MotorA go backwards at full speed simply use set MotorA to -100

For advanced use of steppers – please go here