Classroom units and lesson plans
A unit is a list of problems set in one go, so a week's work takes one click. Six ready-made units ship with PyRasp, built from the practice catalogue; in Teach → your class, under Assignments, open a unit, read its lesson plan, and press Set this unit — the due date and note in the form above apply to every problem it sets. Setting the same unit twice is harmless: problems already set are skipped.
Each unit below is one lesson plan: the goal, the vocabulary to introduce, the problems in the order they work, what to watch for in class, and how to take it further on a real Pi.
First light: LEDs and timing (1–2 weeks)
Goal. Wire an LED safely, light it from Python, and control when and how brightly it shines.
Vocabulary. GPIO pin · anode and cathode · current-limiting resistor · PWM (pulse-width modulation) · duty cycle.
Problems. Two-second glow → Triple flash → Lighthouse → Two rhythms → Upside-down LED → Filling up → Staircase → Sunrise.
What to watch for.
- LEDs the wrong way round: the long leg (anode) goes to the pin, the short leg through the resistor to GND. The simulator is silent — the LED just stays dark.
- Forgetting the resistor. Ask why the real thing would burn out even though the simulator lets it pass.
- Thinking PWM is a dimmer switch. It is fast on/off; Staircase is the moment to make that visible.
On a real Pi. Swap in an RGB LED and compare common-anode and common-cathode wiring; run the same code under pigpio and listen to the difference in jitter.
Buttons, switches and input (2 weeks)
Goal. Read inputs reliably, explain why a floating pin misbehaves, and hold state across presses.
Vocabulary. Pull-up · pull-down · floating pin · debounce · latching · edge vs level.
Problems. Pressed means high → Bring your own pull-up → Blink or steady → Start and stop → Ready, set, go → Left or right? → Short or long → Double-click → Fix the bounce.
What to watch for.
- "It works when I press it" — a floating input looks fine until it does not. External pull-up exists to force the issue.
- Debounce treated as magic. Have them print every edge and count the bounces on Fix the bounce.
- Latching with a blocking loop (
while True: pass). Steer them to checking the button on each pass.
On a real Pi. Add a tactile switch and a 10 kΩ resistor on a breadboard — the wiring matches the simulator; measure real bounce with timestamped logs.
Sensing the world (2 weeks)
Goal. Read a sensor, choose thresholds sensibly, and smooth noisy readings before acting on them.
Vocabulary. Analogue vs digital · threshold · hysteresis · rolling average · calibration · sample rate.
Problems. Fahrenheit, please → Lights on, lights off → Damp alert → Who goes there? → Visitor counter → Comfort zone → Highs and lows → No flicker → Soil check.
What to watch for.
- Thresholds chosen from a single reading. No flicker is where they learn to leave a gap between on and off.
- Averages hiding a spike that matters — talk about how long a window is fair for.
- Distance sensors reading zero or nonsense at the edge of their range; Who goes there makes that a feature.
On a real Pi. A real MCP3008 (SPI) or ADS1115 (I²C) gives the same readings as the simulator's analogue feed; log a day of temperature and compare the rolling average with the raw trace.
Showing numbers and words (1–2 weeks)
Goal. Put a reading on a display, lay text and numbers out, and keep an update loop steady.
Vocabulary. Segment map · common anode/cathode · HD44780 · cursor and backlight · pixel index · refresh rate.
Problems. Name badge → Price tag → Lights out → Error code → Hand-made letters → Quarter marks → Night light → Marquee → Progress bar → Egg timer.
What to watch for.
- Writing to an LCD on every loop pass — the flicker is the lesson.
- Forgetting
clear()before writing shorter text, so the old tail stays on screen. - Pixel counts off by one; have them light pixel 0 and the last one deliberately.
On a real Pi. A real 16×2 LCD needs its contrast pot set before anything shows; drive a real WS2812 strip and compare the timing demands.
Motors, servos and sound (2 weeks)
Goal. Move something with a servo or motor, control its speed and direction, and use sound as feedback.
Vocabulary. Servo pulse · angle vs duty · H-bridge · direction pin · PWM frequency · piezo buzzer.
Problems. Wave hello → Windscreen wiper → Reverse gear → Warm up → Normally closed → Triple beep → Quiet mode → Gentle on the pin → Kick start → Emergency brake → Siren.
What to watch for.
- Jumping a servo straight from 0° to 180°: Windscreen wiper is about easing it there.
- Motors on a GPIO pin directly. Ask what the driver board is for, and what would happen without it.
- Blocking
sleepin the middle of a movement loop, so the button stops responding.
On a real Pi. An SG90 needs a separate 5 V supply — the brown-out is a good discussion; an L298N and a small DC motor uses direction and speed pins exactly as Reverse gear does.
Projects that add up (2–3 weeks)
Goal. Take a one-line brief, decide what to sense and drive, and build it without a step-by-step recipe.
Vocabulary. State machine · input → decision → output · edge case · tolerance · user feedback.
Problems. Wardrobe light → Garage stop light → Hand dryer → Tea is ready → Fridge door alarm → Clap switch → Take a number → Bin gauge → Spirit level.
What to watch for.
- Jumping to code before writing down the states. Ask for the list first.
- Handling only the happy path; Fridge door alarm rewards thinking about the door left open.
- Over-building. Encourage the smallest thing that meets the brief, then one improvement.
On a real Pi. Pick one project and build it for real — a PIR, a reed switch, a buzzer and a breadboard are enough; or have students write the brief for a partner, swap, and build to each other's spec.
Answer keys
Every problem carries a reference solution. A teacher sees it from the assignment list (key next to the assignment) or directly at GET /teach/objectives/<slug>/reference; students never see it, not even on the problem page.