Build it step by step
0 of 8 doneWire the driver
IN1 to IN4 to GP10 to GP13.
Power the driver
Plus to VBUS pin 40, minus to GND.
Wire the knob
Ends to 3V3(OUT) and GND, middle to GP26.
Wire the button
GP14 to GND.
Run the program
Turn the knob up from the bottom.
Watch the shaft
It turns slowly and speeds up.
Press the button
It reverses.
Fix the carousel to the shaft
A card disc with small figures.
How do you build a model carousel?
A 28BYJ-48 stepper turns a cardboard carousel at a speed set by a knob, with a button for the direction. A gentle model for a craft project, powered over USB. You need Raspberry Pi Pico H, 28BYJ-48 Stepper Motor, ULN2003 driver board, Potentiometer 10 kΩ, Tactile push button 6 mm and Breadboard 830 Tie Points. It takes 8 steps and about 130 minutes.
- Level
- Beginner
- Time
- About 130 min
- Parts
- 6
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Driver board IN1 | Pico GP10 pin 14 | Coil A |
| Driver board IN2 | Pico GP11 pin 15 | Coil B |
| Driver board IN3 | Pico GP12 pin 16 | Coil C |
| Driver board IN4 | Pico GP13 pin 17 | Coil D |
| Driver board + | Pico VBUS pin 40 | 5 V from USB for the motor |
| Driver board - | Pico GND pin 38 | Common ground |
| Speed knob ends | Pico 3V3(OUT) pin 36 and GND pin 33 | Knob across 3.3 V |
| Speed knob middle | Pico GP26 pin 31 | ADC0 input |
| Direction button | Pico GP14 pin 19 and GND | Changes direction |
Code
The 28BYJ-48 is a small geared stepper motor, common in toys and cheap kits. A stepper turns in small fixed steps when its four coils are switched on in the right order, and it has a gearbox inside that makes it strong and slow, with about 4096 half-steps for one turn of the shaft. The four pins of the Pico are not strong enough for the coils, so a ULN2003 driver board sits between them and switches the current for each coil. The program steps through eight patterns for a smooth turn, and the time between steps sets the speed, from about one turn in a minute up to about one turn in eight seconds, which is a good carousel pace. The knob sets the speed, with a stop zone at the bottom where the coils are switched off, so the motor does not heat up when it is not moving. A button reverses it. Make the carousel from light card, no heavier than the motor can turn gently, and keep fingers, hair and loose clothing clear. Small parts can be a choking hazard for small children. Run it from a USB port and not from a battery.
from machine import Pin, ADC
import time
coils = [Pin(10, Pin.OUT), Pin(11, Pin.OUT), Pin(12, Pin.OUT), Pin(13, Pin.OUT)]
knob = ADC(26)
button = Pin(14, Pin.IN, Pin.PULL_UP)
# Half-step pattern: eight steps make a smooth turn
SEQUENCE = [
(1, 0, 0, 0), (1, 1, 0, 0), (0, 1, 0, 0), (0, 1, 1, 0),
(0, 0, 1, 0), (0, 0, 1, 1), (0, 0, 0, 1), (1, 0, 0, 1),
]
def release():
for c in coils:
c.value(0) # coils off, so the motor stays cool when stopped
step = 0
direction = 1
last_press = 0
while True:
if button.value() == 0 and time.ticks_diff(time.ticks_ms(), last_press) > 300:
direction = -direction
last_press = time.ticks_ms()
print("Direction", "forward" if direction == 1 else "backward")
reading = knob.read_u16()
if reading < 4000: # knob fully down: stop
release()
time.sleep_ms(50)
continue
delay_ms = 14 - reading * 12 // 65535 # 14 ms (slow) down to 2 ms (fast) per half step
step = (step + direction) % 8
pattern = SEQUENCE[step]
for i in range(4):
coils[i].value(pattern[i])
time.sleep_ms(max(2, delay_ms))Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Knob at the bottom | Motor stopped and cool |
| Knob a quarter up | Slow turn |
| Knob fully up | Faster, but still smooth |
| Press the button | Reverses |
| Run for ten minutes | The motor is only warm |
If it does not work
Motor only buzzes
Check the wire order IN1 to IN4 matches the pins.
Moves jerkily
Increase the delay by turning the knob down a little.
Does not move
Check the driver board has 5 V and GND.
Direction wrong
Press the button or swap the pin order.
Skips under load
Make the carousel lighter or slower.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the model carousel?
Raspberry Pi Pico H, 28BYJ-48 Stepper Motor, ULN2003 driver board, Potentiometer 10 kΩ, Tactile push button 6 mm and Breadboard 830 Tie Points.
How long does the model carousel take to build?
About 130 minutes for a beginner maker, in 8 steps.
How do I know the model carousel works?
Knob at the bottom: Motor stopped and cool. Knob a quarter up: Slow turn. Knob fully up: Faster, but still smooth.
Motor only buzzes: what should I check?
Check the wire order IN1 to IN4 matches the pins.
Moves jerkily: what should I check?
Increase the delay by turning the knob down a little.
Does not move: what should I check?
Check the driver board has 5 V and GND.
Direction wrong: what should I check?
Press the button or swap the pin order.
