TinyGo 2 — Button, debounce, IRQ
Updated
July 30, 2026
TinyGo elective 2 — Button, debounce, IRQ
Elective · ~3h
Goal: Reliable button input with debounce; interrupt path or documented polling fallback; soft-RT reaction notes.
Theory
| Style | Pros | Cons |
|---|---|---|
| Poll + sleep | Portable | Latency tied to loop |
| Pin interrupt | Fast edge | API board-specific; keep ISR short |
| Debounce | Required for mechanics | 5–50 ms typical |
Never toggle LEDs raw on every bounce.
Lab
- Poll
machine.BUTTON(or explicit GPIO) with pull-up; toggle LED on press.
- Add 20 ms debounce (stable samples or ignore window).
- If
SetInterruptexists on your target, set a flag/channel from ISR; handle in main.
- Log 20 presses over UART if available; note multi-fire before/after debounce.
See monorepo Go project 42 for fuller code banks.
Checkpoint
- Clean single toggle per press
- Debounce explained
- IRQ or written N/A for target
Next elective
TinyGo 3 — Timed sensor + UART (94-tinygo-03-…).