Interfacing a Stepper Motor to the Basic STAMP


The software is responsible for pulsing the coils in the proper sequence. There are two ways of driving the coil. The first is by turning on one coil at a time. This gives a smooth rotation, but has low torque. The second is by turning on two coils at a time. This results in high torque, but consumes twice the battery power. For either case, keep in mind that the motor will consume power even when still unless you explicitly turn off all four coils via the STAMP.

The core of the demo code below are the two subroutines, one that turns the motor forward, the other that turns the motor in reverse. You set the speed and number of steps variables, then call the subroutine. As shown, the software executes high torque, high current stepping. To implement low torque, low current stepping, switch the LOOKUP command lines that are commented in the subroutine. The sample code assumes that the stepper is being controlled by Stamp pins 4, 5, 6, and 7.

If you don't understand any of the Stamp commands, look them up in the BASIC Stamp User's Manual

Cut and paste the example code below into your STAMP program.

Stamp example code