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

  1. Poll machine.BUTTON (or explicit GPIO) with pull-up; toggle LED on press.
  2. Add 20 ms debounce (stable samples or ignore window).
  3. If SetInterrupt exists on your target, set a flag/channel from ISR; handle in main.
  4. 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-…).