This project controls servos, reads a PIR sensor, and drives a WS2812 LED strip for a "Spy Game" setup.
| Component | Pin | Notes |
|---|---|---|
| Servo Left/Right | D7 | |
| Servo Up/Down | D6 | |
| PIR Sensor | D5 | Signal Pin |
| WS2812 LED Strip | D4 | Data Pin |
| PIR Disable Switch | D0 | Connect to 3.3V for PATROL, Disconnect for GAME |
| Green Button | D3 | Connect to GND (PULLUP) |
| Yellow Button | D2 | Connect to GND (PULLUP) |
| Red Button | D1 | Connect to GND (PULLUP) |
Note on D0 Switch: D0 has an internal pull-down resistor.
- Patrol Mode: Switch Closed (Connected to 3.3V).
- Game Mode: Switch Open (Disconnected/Low).
- Connect Device: Plug your ESP D1 Mini into your computer via USB.
- Open Project: Open this folder in VS Code with the PlatformIO extension installed.
- Build: Click the Checkmark icon (โ) in the bottom PlatformIO toolbar.
- Upload: Click the Right Arrow icon (โ) to upload.
- Monitor: Click the Plug icon (๐) to see serial output.
Run these commands in the project root:
- Build Project:
pio run - Upload to Device:
pio run --target upload - Open Serial Monitor:
pio device monitor - Upload & Monitor:
pio run --target upload -t monitor - Clean Build Files:
pio run --target clean
To see the system status (Inputs, Switch State, Game Mode events):
- Run
pio device monitorin the terminal. - Or use the Plug Icon (๐) in VS Code.
Debug Output format:
[inputs] Switch(D0):1 | PIR(D5):0 | Btns(G/Y/R):1/1/1
- Switch:1: Patrol Mode (Connected to 3.3V)
- Switch:0: Game Mode (Open/Low)
- Btns: 1 = Not Pressed, 0 = Pressed
- Port not found: Ensure you have the correct drivers (CH340 or CP210x).
- Upload Failed: Hold RESET during "Connecting..." or check cable.