GPIO 17 → HIGH PWM duty 60% servo.angle = 90

Make the real world
obey your code.

You've mastered electrons in CIRCUIT FORGE. Now meet the brain that commands them. Wire LEDs, motors, buzzers and sensors to a Raspberry Pi 5, write a few lines of Python, and watch atoms move — all simulated right here in your browser. No fried components, no missing jumper wires, infinite undo.

40GPIO header pins, accurately mapped
12+preloaded, editable Python examples
25+draggable components & sensors
3Dorbitable breadboard workbench

From the screen to the world

Every program you've written so far has lived inside a screen. Physical computing breaks the glass. The Raspberry Pi 5 is a full Linux computer the size of a credit card with a row of pins — its GPIO header — that can switch real voltage on and off thousands of times a second. Your Python becomes light, motion, and sound.

It's the same chip running behind smart doorbells, retro game emulators, weather stations, robot rovers, 3D-printer farms and the high-altitude balloons students launch to the edge of space. Learn it here, then build it for real on the classroom Pi fleet.

The progression
🔌
Electronics
Volts, current, resistance — CIRCUIT FORGE
↓
🧩
Components
LEDs, motors, sensors & what each one does
↓
🍓
Pi 5 + Python
Code that controls the components — you are here
💡

Lights

Blink, fade and sequence LEDs, RGB LEDs and NeoPixel strips with digital and PWM output.

⚙️

Motors

Spin DC motors through an L298N driver, sweep servos to exact angles, step a stepper motor.

🛰️

Sensors

Read buttons, light (LDR), motion (PIR) and distance (ultrasonic) and react in real time.

🔔

Actuators

Drive buzzers, relays and vibration motors — output that does something physical.

Meet the Raspberry Pi 5

A single-board computer (SBC): a complete computer — CPU, RAM, USB, networking, video — on one board. What makes it special for us is the 40-pin GPIO header along one edge. Hover any pin below to learn its job.

RASPBERRY PI 5 · 40-PIN GPIO HEADER · (BCM numbering)
Power (3V3/5V) Ground (GND) GPIO (general use) I²C / SPI / UART PWM-capable
Physical vs BCM: Pins also have a physical number (1–40, the position on the header). In Python with gpiozero we almost always use the BCM/GPIO number — e.g. LED(17) means BCM GPIO 17, which is physical pin 11.
Hover a pin →

Move your mouse over any pin on the header to see its number, function, safe use and a code hint.

Pi 5 reality check: The Pi 5 uses a new RP1 I/O chip, so the old RPi.GPIO library no longer works the classic way. The modern, correct choice on a Pi 5 (Raspberry Pi OS or Kali) is the gpiozero library, which talks to the pins through the lgpio backend. Everything in this lab teaches the gpiozero way.
Golden safety rule: GPIO pins run at 3.3 V, not 5 V, and can only supply a tiny current (~16 mA). Always use a resistor with an LED, and never feed 5 V back into a GPIO input — it can kill the pin.

Python + GPIO with gpiozero

gpiozero was built to make hardware readable. You describe what a thing is and the library handles the messy electronics. Here's the anatomy of the classic "Hello World" of hardware — the blinking LED.

Before you start — one-time setup on your Raspberry Pi 5

Open a Terminal on the Pi and install the libraries. The Pi 5 talks to its pins through the lgpio backend, so install that too. These steps work whether your Pi 5 runs Raspberry Pi OS or Kali Linux.

Raspberry Pi OS (Bookworm)
# gpiozero + lgpio ship with the OS, but make sure they're current
sudo apt update
sudo apt install -y python3-gpiozero python3-lgpio
Kali Linux (on the Pi 5)
# Kali doesn't ship them — install with apt (preferred)
sudo apt update
sudo apt install -y python3-gpiozero python3-lgpio

# ...or, inside a virtual environment, with pip:
pip install gpiozero lgpio
Why lgpio? The Pi 5's new RP1 I/O chip isn't supported by the old RPi.GPIO. Every lab below starts by pinning the lgpio backend explicitly:
from gpiozero import LED, Device
from gpiozero.pins.lgpio import LGPIOFactory

Device.pin_factory = LGPIOFactory()   # Pi 5: same on Raspberry Pi OS & Kali
That one line makes the identical program run on both operating systems — no per-OS edits.
Run a program: save it as e.g. blink.py, then in the Terminal: python3 blink.py. Press Ctrl+C to stop a forever-loop.
Anatomy of a blink
# import the tools we need
from gpiozero import LED
from time import sleep

# create an LED object on GPIO 17
led = LED(17)

while True:        # repeat forever
    led.on()       # 3.3V — light ON
    sleep(1)        # wait 1 second
    led.off()      # 0V — light OFF
    sleep(1)        # wait 1 second

Four ideas power almost everything: import a device class, create an object tied to a pin, call methods on it (.on(), .off()), and control timing with sleep() and loops.

Two ways to "talk" to a pin

Digital — ON or OFF

led.on() / led.off(). The pin is either 3.3 V (1) or 0 V (0). Perfect for switching things hard on and off.

PWM — anywhere in between

Pulse-Width Modulation flicks the pin on/off so fast your eyes see a dimmed light or a motor at half speed. PWMLED(17).value = 0.5 = 50% brightness.

The water analogy (carried over from CIRCUIT FORGE)

Voltage = water pressure (the Pi pushes at 3.3 V). Current = how much water flows. A resistor is a narrow section of pipe that limits the flow so your LED doesn't burn out.

Inputs vs Outputs

Outputs (LED, Buzzer, Motor, Servo) — the Pi pushes voltage out to make things happen.
Inputs (Button, LDR, PIR, Ultrasonic) — the Pi listens for a voltage coming in and reads the world.

Your programs almost always follow the loop: read inputs → decide → drive outputs → repeat. That's robotics in one sentence.

⚡ Workbench drag-orbit · scroll-zoom
🧩 Components
● idle
🛰️ Live Inputs you are the world
The green ▶ Run button is top-left. Wire it: click a Pi pin, then click the LED’s leg (or its breadboard hole). Legs glow green = connected, red = floating. Right-click a wire to move an end onto a leg, or drag the LED so its legs sit under the wire ends.
📘 Lab Guide
⌨️ Code
1

Missions

Each mission loads into the Lab with a starter so you can focus on the new idea. Read the goal, edit the code (and the wiring!), run it, and see if you cleared it.

Evaluation

Twelve questions across pins, Python and components. Answer all, then submit for an instant score, badge and per-question feedback.