Alternating police lights
A 200 ms interval toggles GPIO9/10 and GPIO3/2. Each pair has an interlock and a 200 ms changeover delay. The dashboard adds red/blue reflections around the illustrated car.
Adjustable two-tone siren
GPIO8 alternates between configurable low and high frequencies. Defaults are 850 and 950 Hz; each tone adjusts from 100–3000 Hz. Volume is a 0–100% PWM setting, with a master siren enable.
Mount-aware tilt calibration
Capture flat, front-lift, and side-lift positions, solve the car axes, then zero the level reading. Solved axes and zero offsets are saved across restarts.
Stable level feedback
Moving averages smooth the acceleration and angle readings. A 0.3° deadband reduces jitter near zero; the car-level sensor is true when both tilt angles are within ±2°.
Battery visibility
The 3.7 V, 650 mAh LiPo battery has two firmware readings: Battery Voltage in volts and Battery Level as an estimated percentage. Voltage is measured through XIAO D2/A2 (GPIO4); percentage is calculated from that same reading, with no second pin.
Awake / sleep awareness
The car publishes active at boot and inactive one second before deep sleep. Adjustable defaults are 30 seconds awake and 30 minutes asleep. A motion-sensitivity setting and GPIO5 wake input are configured.
Sleep duration and motion sensitivity are applied during boot in the supplied reference. Verify the MPU interrupt connection and wake behavior on the assembled car; physical operation has not been tested here.