# ZT Zombie Robot firmware (ESP32-C6)

BLE-controlled differential drive for the Cardboard Zombie. Board: ESP32-C6-DevKitC-1, Arduino core esp32 3.x.

## BLE
- Device name: `ZT-Zombie`
- Service UUID: `7a7e0001-5a7d-4c1e-9b6e-2d0e5a0b1e01`
- Command characteristic (write / write-without-response): `7a7e0002-5a7d-4c1e-9b6e-2d0e5a0b1e01`
- Commands (ASCII): `forward`, `back`, `left`, `right`, `stop`, `speed:1`..`speed:5` (20/40/60/80/100 %)
- `left`/`right` spin wheels in opposite directions. Motors stop if no command for 500 ms (send keepalives every ~200 ms). Speed changes ramp in 10 ms steps. Drivers disabled at boot and on disconnect.

## Wiring
| ESP32-C6 | Goes to | Purpose |
|---|---|---|
| GPIO1 (J1 pin 8) | Left BTS7960 RPWM | left wheel forward PWM |
| GPIO0 (J1 pin 7) | Left BTS7960 LPWM | left wheel backward PWM |
| GPIO11 (J1 pin 11) | Right BTS7960 RPWM | right wheel forward PWM |
| GPIO10 (J1 pin 10) | Right BTS7960 LPWM | right wheel backward PWM |
| GPIO7 (J1 pin 6) | R_EN + L_EN on BOTH drivers | enable / emergency stop (LOW = off) |
| 5V (J1 pin 14) | Buck 5V out + both BTS7960 VCC | logic power |
| GND (J1 pin 15) | Buck GND, both BTS7960 GND, battery − | common ground (required) |

Power: 12V battery → fuse (10–15 A) → switch → both BTS7960 B+/B− and the 12V→5V buck. Motors (12V 5840-31ZY) on each driver's M+/M−; swap wires if a wheel runs backwards. Solar panel → charge controller → battery.
All motor signals are on the J1 pin row, so the connector board (hub v5) plugs straight onto it.
Avoided pins: strapping 4,5,8,9,15; GPIO6 (pull-up at reset); USB 12/13; flash 24–30. GPIO2/GPIO3 are kept for the HC-SR04 ultrasonic sensor (TRIG/ECHO).

## Build
Arduino IDE / arduino-cli, board `esp32:esp32:esp32c6`, built-in BLE library (no extra libs).
Serial monitor 115200 prints the UUIDs at boot.
