Robotics modules and the Pico IO shield
The pilot hardware is a Raspberry Pi Pico on a Keyestudio KS3017 Pico IO shield. The shield does not change the Pico's pins: it brings them to labelled G / V / S headers so a module can be plugged in without a breadboard.
In the simulator the Pico is shown mounted on the shield, with eight G/V/S module headers around it. Wire a module's S to the header's signal pin, its V to a 3.3 V or 5 V header pin, and its G to a ground header. Those header nets are the same nets as the Pico GP pads, so Pin(13) sees a module on S1 exactly as it would on the real shield.
| Header | Signal | Header | Signal |
|---|---|---|---|
| S1 | GP13 | S5 | GP20 |
| S2 | GP16 | S6 | GP21 |
| S3 | GP12 | S7 | GP26 |
| S4 | GP18 | S8 | GP27 |
The 3.3 V headers are V33_1–V33_4; the 5 V headers are V5_1–V5_4. G1–G8 are ground. Choose the V header that matches the module, and set the physical shield's selector to match.
Power and the voltage selector
The KS3017 has a 3.3 V / 5 V selector for the module rail.
- 3.3 V modules — line sensor, obstacle sensor, PIR, DHT11, OLED, potentiometer, button: use 3V3. Their signal outputs are safe for a Pico GPIO.
- 5 V modules — servos, the HC-SR04, NeoPixel strips: use 5 V from VBUS. Their signal still has to be safe for the Pico:
- HC-SR04 ECHO is 5 V. Divide it with 1 kΩ + 2 kΩ before the GPIO, or use a 3.3 V-safe module.
- A 5 V servo's signal input usually accepts 3.3 V, but power the servo from 5 V, never from 3V3.
- Common ground is not optional. Every module's G and the Pico's GND must meet, even when the module has its own supply.
Check the selector before plugging anything in. A 3.3 V module fed 5 V, or a 5 V signal into a GPIO, can damage the part or the Pico. The simulator warns and then damages the pin in the same way.
The module set
| Module | Signal behaviour | Pico connection | First problem |
|---|---|---|---|
| LED module | lit when SIG is high | SIG → GP13, G → GND | First blink |
| Traffic light | red/yellow/green, shared ground | three GPIOs | Traffic light |
| Button module | OUT high while pressed (pull-down fitted) | OUT → GP12, V → 3V3 | Button mirror |
| Active buzzer | beeps while powered | GP13 (piezo) or through a transistor (magnetic) | Buzzer button |
| Potentiometer | 0–3.3 V on the wiper | W → GP26 | Pot → LED brightness |
| LDR module | voltage falls in light | AO → GP26 | Night light |
| Servo | 0.5–2.5 ms pulse → angle | SIG → GPIO, V → 5 V | Servo sweep |
| HC-SR04 | ECHO pulse width is distance | TRIG S5, ECHO S6 (divide) | Print the distance |
| Line sensor | OUT high over a dark line | S2, V33, G1 | Line sensor → LED |
| Obstacle sensor | OUT high when something is close | S2, V33, G2 | Obstacle stop |
| PIR | OUT high on motion | S2, V5, G1 | PIR alarm |
| Joystick | two pots + button | two ADC pins + GPIO | Joystick → two servos |
| 6812 RGB stick | one data line, GRB bytes | S4, V5, G1 | Colour the stick |
| DHT11 | temperature and humidity | GP15, V33, G2 | Temperature and humidity |
| OLED | SSD1306 over I²C | SDA GP4, SCL GP5 | Write on the OLED |
The line and obstacle sensors are comparator modules: the IR emitter and receiver produce an analogue reflection, and the trimmer sets the trip point. The Pico sees only a clean digital HIGH or LOW, which is why Pin(16, Pin.IN) is enough.
The twelve-problem robot unit
Work through these in order. All twelve are in the catalogue; the joystick problem uses two potentiometers, which is what is inside the module.
- Blink the on-board LED —
Pin('LED'), no wiring. - Traffic light — three outputs and a timed sequence.
- Button mirror — one input, one output.
- Pot → LED brightness — ADC and PWM.
- Pot → servo angle — map a voltage to a pulse width.
- Print the ultrasonic distance —
time_pulse_us. - Distance alarm — closer means faster beeping.
- Line sensor → LED — read a comparator output.
- Obstacle stop — stop a motor when the path is blocked.
- PIR alarm — motion turns on a warning.
- Joystick → two servos — two ADCs, two PWM outputs.
- Parking sensor — ultrasonic + buzzer + warning LED.
A line follower's first test
from machine import Pin
import utime
sensor = Pin(16, Pin.IN)
while True:
print("line" if sensor.value() else "floor")
utime.sleep_ms(50)
Move the module across black tape. If it never changes, check the 3V3 supply, the G/V/S order, and the trimmer. The simulator's line feed is the trimmer's decision; on real hardware, adjust the trimmer until the module's indicator LED changes at the line edge.
An obstacle stop
from machine import Pin
import utime
sensor = Pin(16, Pin.IN)
in1, in2, ena = Pin(20, Pin.OUT), Pin(21, Pin.OUT), Pin(22, Pin.OUT)
in2.off()
while True:
if sensor.value(): # something is close
in1.off()
ena.off()
else:
in1.on()
ena.on()
utime.sleep_ms(20)
The obstacle module's OUT is already 3.3 V, so no divider is needed. The L298N's motor supply is a separate 5 V feed; the Pico only drives the logic inputs and ENA.
A parking sensor
The HC-SR04 needs a 10 µs trigger pulse and returns a pulse whose width is twice the travel time. Sound travels about 58 µs per centimetre at room temperature, so:
distance_cm = time_pulse_us(echo, 1, 30000) / 58
The reference program in the catalogue beeps and lights a red LED below 20 cm. With a real HC-SR04, divide ECHO down to 3.3 V before the Pico. With the 3.3 V-safe module, connect it directly.
Troubleshooting the shield
| What you see | Likely cause | Fix |
|---|---|---|
| Module has no power | V/G swapped, or the rail selector is off | Check G/V/S order; measure V against G |
| Sensor always reads 1 | Input floating, or pull-up left on | Use Pin.IN with a real driven signal; don't add a pull unless the module needs one |
| Servo jitters or browns out | Servo powered from 3V3 | Move V to 5 V (VBUS); share ground only |
| Pico resets when the motor starts | Motor current sharing the Pico supply | Separate motor supply; common ground |
| HC-SR04 gives 0 or a timeout | ECHO not divided, or TRIG pulse too short | 1 kΩ + 2 kΩ divider; 10 µs trigger |
| OLED stays black | SDA/SCL swapped or address wrong | SDA GP4, SCL GP5, address 0x3C |
Problems: Line sensor → LED · Obstacle stop · PIR alarm · Parking sensor