# Wokwi simulation — PM‑µ Micro (Raspberry Pi Pico)

A runnable [Wokwi](https://wokwi.com) simulation of the **PM‑µ Micro** metronome on a
Raspberry Pi Pico (RP2040), in MicroPython. It's a *functional* stand‑in — Wokwi has no
14‑segment display or analog audio path, so we approximate:

| Real device | Simulated with |
|---|---|
| Clickable thumb‑roller | **KY‑040 rotary encoder** (rotate / press / hold+rotate) |
| Amber 14‑segment display | **SSD1306 OLED** (shows BPM and track names) |
| Analog click + speaker | **Piezo buzzer** (accent beat = higher, longer beep) |

### Controls
- **Rotate** the encoder → tempo (BPM)
- **Press** (the encoder's button) → start / stop
- **Hold the button + rotate** → switch track (release to load it)

## Run it (you do this part — I can't operate your Wokwi account)
I can't log into wokwi.com or create the project on the site for you. Use these files:

1. Open **https://wokwi.com/pi-pico** — it starts a new Pi Pico **MicroPython** project.
2. Click the **`diagram.json`** tab and replace its contents with this folder's `diagram.json`.
3. Replace **`main.py`** with this folder's `main.py`.
4. Add a new file named **`ssd1306.py`** (the **＋** next to the file tabs) and paste this folder's `ssd1306.py`.
5. Press **▶ (play)**. Rotate / click the encoder; you'll hear the click and see the OLED update.

> If you use the Wokwi VS Code extension instead, keep these three files together and add a
> `diagram.json` reference as usual.

## Pin map (Pico GPIO)
| Function | Pin |
|---|---|
| OLED SDA / SCL (I²C0) | GP0 / GP1 |
| Encoder CLK / DT / SW | GP2 / GP3 / GP4 |
| Buzzer | GP5 |
| OLED + encoder power | 3V3 / GND |

The real firmware ("PORTS TO FIRMWARE" in the web app) drives a 14‑segment display over
I²C and injects the click into the analog signal path; this sim keeps the same control
model and beat scheduling so the *feel* matches.
