Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsA 28BYJ-48 stepper moves in tiny steps, so it can hold an exact position without feedback. The program reads the knob, works out the matching step count and moves one step at a time towards it. When it arrives it switches the coils off so the driver stays cool.
Tick anything you already have and the total updates.
Small geared stepper motor (2048 steps per turn) with its ULN2003 driver board.
A 10 kΩ knob that works as a voltage divider, giving an analog value you can map to anything.
Follow the colours: red is power, dark grey is ground, blue is a signal.
main.py# Pico stepper dial: a knob sets the angle of a 28BYJ-48 stepper (MicroPython)
from machine import Pin, ADC
import time
pins = [Pin(10, Pin.OUT), Pin(11, Pin.OUT), Pin(12, Pin.OUT), Pin(13, Pin.OUT)]
knob = ADC(26)
SEQ = [(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)] # half steps
STEPS_PER_REV = 4096
position = 0
def move(direction):
global position
position += direction
pattern = SEQ[position % 8]
for p, v in zip(pins, pattern):
p.value(v)
def release():
for p in pins:
p.value(0)
while True:
target = knob.read_u16() * STEPS_PER_REV // 2 // 65536 # half a turn across the knob
if abs(target - position) > 2:
move(1 if target > position else -1)
time.sleep_ms(2)
else:
release() # let the coil cool when it has arrived
time.sleep_ms(20)
Pin order is wrong: it must be IN1, IN3, IN2, IN4 in the Stepper constructor. Keep speed under 15 rpm.
The wiper is on an outer pin. Move the signal wire to the middle leg.
5 parts: 28BYJ-48 Stepper Motor & ULN2003 Driver Kit, 16mm Rotary Potentiometer 10kΩ (Linear), Raspberry Pi Pico, Solderless Breadboard (830 points) and Dupont Jumper Wires (40 pcs). Tools: Digital Multimeter and Wire Stripper and Cutter. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 45 minutes. The build on this page has 4 steps.
No. This page has the complete, tested code (main.py).
About ₹615 for the parts at the prices on this page, plus tools if you do not have them. Quantity price breaks lower the cost when you build several.
Stepper motors and step sequences; Voltage dividers and analogRead().
Ideas that reuse this build: Stepper dial thermometer and Pico servo knob control. They are listed under Take it further on this page.
Your first MicroPython project: temperature and humidity on an OLED.
A web page with ON and OFF buttons that switches a relay over Wi-Fi.
A warm ring light that fades up at dusk and down at dawn.
Turn a Pi and a touchscreen into a home command centre with a clock and to-do list.
Learning project. Check every circuit and the datasheet of each part before you power it up.