Raspberry Pi and Pico
What you’ll learn
- The difference between a Raspberry Pi and a Raspberry Pi Pico
- When a robot needs a full computer
- How Pi and microcontroller can work together
Two very different boards
| Raspberry Pi (e.g. Pi 4 / Pi 5) | Raspberry Pi Pico | |
|---|---|---|
| Type | Full computer running Linux | Microcontroller |
| Runs | Python, OpenCV, ROS 2, a desktop | One program: MicroPython or C/C++ |
| Starts up in | Tens of seconds | Instantly |
| Power | 5 V, several amps (the Pi 5 wants a 27 W USB-C supply) | Tiny |
| Good at | Cameras, AI, maps, Wi-Fi, heavy maths | Precise timing, reading sensors, driving motors |
| Price | ~$35–80 | ~$4–7 |
Using a Pi in a robot
- Program it in Python; the gpiozero library makes pins easy.
- Add a camera for computer vision.
- It’s not real-time, so for precise motor timing many robots pair a Pi (brain) with a microcontroller (spinal cord): the Pi decides “turn left”, and a Pico or Arduino runs the motors and reads encoders.
Example: gpiozero on a Raspberry Pi
from gpiozero import Robot, DistanceSensorfrom time import sleep
robot = Robot(left=(4, 14), right=(17, 18)) # motor driver pinssensor = DistanceSensor(echo=24, trigger=23) # use a divider on ECHO
while True: if sensor.distance < 0.2: # metres robot.right(0.5) else: robot.forward(0.6) sleep(0.05)Example: Pi talks to a Pico over USB serial
The Pi sends "L 120\n", the Pico reads the line and sets the left motor to 120. The Pi does the thinking; the Pico does the timing.
Try it in a virtual Raspberry Pi Pico
Press Start simulator, paste into main.py, and press ▶.
from machine import Pinimport time
led = Pin(25, Pin.OUT)while True: led.toggle() print("tick") time.sleep(0.5)Runs on Wokwi, free, no account needed.
Pi or Pico?Easy
Which would you choose for: a robot that recognises faces; a precise stepper plotter; a battery-powered line follower? Pi (camera + AI); Pico (precise timing); Pico (simple, low power, instant start).
SOS on the PicoMedium
Blink SOS on the virtual Pico’s LED.
Brain and spinal cordHard
Design the split of jobs between a Pi and a Pico for a robot that follows a coloured ball. Pi: camera, find the ball’s position, decide the steering. Pico: read encoders, run a PID loop on wheel speeds, receive speed commands from the Pi over serial.
Quick check
Finished this lesson?