“If it balances for one second, it will balance for ten — as long as your loop is honest.”
// PlatformIO (Nano/ESP32) — core loop sketch
void loop() {
const float dt = microsUpdate(); // ~1–2 ms
float ax, gy; readIMU(ax, gy); // raw accel & gyro
theta = alpha* (theta + gy*dt) + (1-alpha)*accAngle(ax); // complementary
float u = kp*theta + kd*gyroLPF(gy) + ki*integrate(theta); // PD(+I)
u = applyDeadzoneFF(u, dz, ff); // compensate
setMotorVoltage(constrain(u, -Umax, Umax)); // H-bridge PWM
sendTelemetryIfNeeded(theta, u); // ESP-NOW/BLE
}
TL;DR for hiring managers: I designed and shipped the core control loop, electronics, power, and CAD for a self-balancing robot, moving from Arduino Nano to ESP32 under PlatformIO, integrating H-bridge motor control, LiPo power distribution, Bluetooth/ESP-NOW comms, and 3D-printed hardware (PLA/TPU). It balances — and I can explain exactly why.