Python & GPIO: code meets circuit
420-302-VA · WEEK 4 · FALL 2026

Utility · sources and further reading

Resources

Everything this hub teaches is checked against the documents below. Same rule as every week: when a tutorial found in a search disagrees with these, these win.

Official documents

DocumentUse it forLicence
The Python TutorialThe language, from the source; chapters 1–4 cover this weekPSF documentation licence
venv, standard library docsExactly what a virtual environment is and every optionPSF documentation licence
Packaging Guide: pip and virtual environmentsThe pip + venv workflow, including requirements.txtPyPA, open documentation
gpiozero documentation · recipesEvery component class, with wiring diagrams; the recipes are this course's example bankBSD-licensed project docs
Raspberry Pi hardware documentationThe authoritative GPIO electrical descriptionCC BY-SA 4.0
Raspberry Pi OS documentationPython on the Pi, the venv policy, --system-site-packages adviceCC BY-SA 4.0
pinout.xyzThe interactive header map; the pinout command is its terminal twinCommunity reference (CC BY-SA)

Background reading, matched to the stages

StageRead this for the ideas behind it
Python from zeroOfficial tutorial ch. 1–4; Automate the Boring Stuff ch. 1–3 for a project-flavoured second telling
EnvironmentsThe Packaging Guide for the workflow; venv docs for the mechanism
GPIO, safelyHardware documentation GPIO section; pinout.xyz per pin
First lightgpiozero recipes: LED, Button, and everything your kit can build next

Reading order for a beginner: this hub, then Automate the Boring Stuff for fluency, then the official tutorial when you want precision, with the gpiozero recipes as the standing invitation to build.

Practice

  • Automate the Boring Stuff with Python: the free classic for beginners; readable on any device, exercises included. This week's homework uses its first chapters.
  • Raspberry Pi Foundation projects: guided Python and electronics projects at exactly this level, many using the same kit parts.
  • gpiozero recipes: not just reference; each recipe is a buildable exercise. The remote-GPIO chapter of the same docs shows how to drive the Pi's pins from another computer at home.
  • Thonny: the beginner Python editor preinstalled on the Pi desktop. This course works over SSH with nano for good reasons (headless habits), but at the Pi's own desk Thonny's debugger, which steps through code line by line, is genuinely instructive.

Glossary

TermMeaning
InterpreterThe python3 program that executes your script's text, line by line.
REPLThe interactive >>> prompt: read, evaluate, print, loop.
ScriptA .py file run start to finish by the interpreter.
Variable / typeA name bound to a value; the value's kind (int, float, str, bool).
f-stringf"text {value}": text with values spliced in.
Module / importA unit of borrowed code; the statement that brings it into your program.
pip / PyPIPython's package installer / the index it installs from.
Virtual environmentA project-private Python setup in a .venv folder, activated per session.
externally-managed-environmentDebian's refusal of bare pip on the system Python; the signpost toward venvs.
requirements.txtThe committed recipe (pip freeze) from which an environment can be rebuilt.
GPIO / BCM numberingThe programmable header pins / the SoC channel numbers (GPIO17) that gpiozero uses.
Pull-up / pull-downA resistor (internal here) giving an input a defined idle level instead of floating.
Debounce / bounce_timeMerging a mechanical contact's chatter into one logical press.
Polling / event-drivenAsking in a loop versus registering a function the library calls when something happens.
TracebackPython's error report; read from the bottom line up.
gpiozeroThe Raspberry Pi Foundation's Python library for GPIO components.

← Troubleshoot · Start here · Week 3 hub · Week 2 hub