MakeCode Steppers

Stepper motors are used in many projects and you can use them with Crickit and MakeCode.

 

The Circuit Playground Express + Crickit connections are shown at left.

And the micro:bit can control stepper motors also when plugged into the micro:bit version of Crickit (micro:bit not shown for clarity).

You can control one or two stepper motors on Crickit. The Motor block can drive one bipolar stepper (wiring shown above) or one unipolar stepper. In addition, the Drive block can control one stepper also but it must be unipolar (bipolar will not work on the Drive port).

The MakeCode blocks to control a unipolar/bipolar stepper on the Motor port is DIFFERENT from the block used to control a unipolar stepper on the Drive port. Be sure you use the correct block depending on the block you are wiring the stepper motor to.

MakeCode for Using a Stepper on the Motor Port

In the CRICKIT block group, scroll down until you see the Stepper heading and the block crickit stepper move block. Be sure not to use the crickit drive stepper move block, that is for using a unipolar stepper on the Drive port, discussed further down the page.

Move the Motor Port Stepper One Direction Forever

Here is a simple program that tells the stepper to move 20 steps, then wait 10 milliseconds, and repeats forever:

You'll see the motor shaft slowly turning in the "positive" direction. If you use a bit of solid tape on the stepper's shaft as a small flag, you can see the rotation better. If the rotation is in the wrong direction, use a negative value for the number of steps, re. -20.

At this point, you can vary the parameters: increase or decrease the number of steps moved every loop. If you want the stepper to move faster, increase the steps. This may make the action a bit "jerky". If so, you can decrease the steps. This will be smooth, but slow. To increase the pause between steps, you can use the pause block to get times greater than 10 milliseconds.

Using a Stepper on the Drive Port in MakeCode

In the CRICKIT block group, scroll down until you see the Stepper heading and the block crickit drive stepper move block.

Move the Drive Port Stepper One Direction Forever

Here is a simple program that tells a stepper on the Drive port to move 20 steps, then waits ten milliseconds, and repeats forever. 10 milliseconds delay between step blocks is the minimum to ensure the stepper doesn't miss any steps between blocks.

If you want to move the motor in the opposite direction, make the movement value negative, re. -20. The block takes positive and negative values.

This guide was first published on May 16, 2018. It was last updated on May 16, 2018. This page (MakeCode Steppers) was last updated on Sep 19, 2019.