Stage 6 of 6 · Logistics, evidence, next steps
Lab & hand-in
No graded demo today; the grade pressure returns with the midterm in three weeks. Instead the lab has a ladder: everyone reaches the toggle, and the rungs above it separate "it ran" from "I can build with it". Here is the clock, the evidence, and the road to Week 5.
The two hours
| Minutes | You do | Checkpoint before moving on |
|---|---|---|
| 0–10 | Wire the station (Week 2 order), boot, SSH in from the lab PC. | Key-based SSH prompt shows username@lastname-pi. |
| 10–25 | Environment: create ~/iot/week4/.venv, activate, test pip, write .gitignore, first commit. | (.venv) in the prompt; import gpiozero succeeds. |
| 25–45 | Python warm-up: REPL arithmetic, hello.py with variables and an f-string, a loop with sleep(), one traceback caused and fixed. | Both partners have typed and run code, not watched it. |
| 45–55 | Wire the LED and button, powered down; trace aloud. | Verifier signs off pin-by-pin against the diagram. |
| 55–95 | First light: blink.py, press.py, events.py, toggle.py, committing after each. | Toggle works; git log --oneline shows the four steps. |
| 95–110 | The practice ladder, as far as time allows. | Each rung committed separately. |
| 110–120 | Assemble and upload the evidence, answer the exit ticket, clean shutdown, pack. | Drive returned; kit packed; station restored. |
Working as a pair
Same operator/verifier discipline as Weeks 2 and 3, with a twist suited to code: swap at the keyboard, not just at the checklist. Partner A types the Python warm-up while B verifies; B types the circuit scripts while A verifies the wiring and reads the diagrams. Both push commits from their own account where machines allow (the shared Pi user is fine; the commit author from Week 1's config is what traceability reads). The midterm is individual; a partner who only watched this lab will feel it in Week 7.
The practice ladder
In order of difficulty; each rung is a separate script and a separate commit. Rung 3 upward is excellent midterm preparation.
Heartbeat
Change
blink.pyto awhile True:heartbeat: short on, long off. One variable controls the tempo. (Loop and variables.)SOS
Blink the pattern three-short, three-long, three-short, using a function
flash(duration)called from loops. (Functions with parameters.)Press counter
Extend
events.py: count presses in a variable and print the running total in the handler. (State that survives between events.)Hold-to-arm
LED lights only while the button is held:
when_pressed = led.on,when_released = led.off. Then invert it. (Two events, one system.)Double-blink acknowledge
On each press, blink the LED twice quickly, then return to its previous state. Requires an
ifonled.is_lit, a loop, and thought. (Everything at once.)
What to hand in
Most of the evidence is your repository, which is the point. Assemble the rest with scp exactly as in Week 2's practice, then upload to Omnivox:
| Item | How to produce it | Shows that |
|---|---|---|
| Repository URL | Paste into the Omnivox form | hello.py, the four circuit scripts, ladder rungs, and .gitignore, with commits from both partners |
env.txt | (.venv) $ python --version > env.txt && which python >> env.txt && pip list 2>/dev/null | head -n 15 >> env.txt | The environment exists, is active, and can import the GPIO stack |
circuit.jpg | Phone photo of the breadboard with the LED lit, both loops visible | The wiring matches the diagram and worked |
station.txt | Typed in nano | Station number, Pi model, boot-drive label, both names, exit-ticket answers if asked |
Counts as completion of in-class work. Private keys never appear in evidence (Week 3's rule stands), and neither does the .venv folder (this week's).
Exit ticket
Answer without looking at the hub; write the answers at the end of station.txt if the teacher asks for them.
- What does the interpreter do with
blink.py, line by line? - Why did
pip installfail outside the venv, and what made it work inside? - Recompute the LED current with the resistor from your kit. Is it inside the pin budget?
LED(17): which physical pin is that, and how do you check?- Polling versus events: which did
toggle.pyuse, and why does it needpause()?
Packing up
Homework and next week
This week's homework (2 h)
Make the syntax automatic
Finish any ladder rung left undone. Read chapters 1 and 2 of Automate the Boring Stuff (free online) and do their small exercises in the REPL, on any computer. Browse three gpiozero recipes that use parts from your kit and note, in your journal, one you want to build; the journal feeds the Week 7 reflection log.
Week 5 · September 28
Requirements and pseudocode
This week you built from a finished diagram and finished code. Next week you learn to produce those yourself: stating what a system must do as testable requirements, sketching how in pseudocode, and only then writing Python. It is the working method of Assignment 2 and the project. Bring the breadboard kit; the exercises stay hands-on.