Self-balancing
robot

no. 6

A two-wheeled robot that stays up by correcting itself hundreds of times a second. It also hears the beat in music and dances.

IMU
gyro and accelerometer
PID
control loop
DFT
beat detection
Self-balancing robot
Sense
A gyro is fast but drifts. An accelerometer is steady but noisy. Blend them for a clean tilt angle.
Control
A PID loop turns tilt into wheel speed. A knob and a small screen tune it live.
Dance
A microphone signal is split into frequencies to find the beat, and the robot moves to it.

Watch

Balancing
Dancing to music
Beat and volume detection

Try it

It works like balancing a broom on your hand. Gravity pulls the robot over as soon as its centre of mass leaves the upright line. The controller measures the tilt and has the motors drive the wheels towards the lean, so the axle catches up underneath. Turn the gains down and it topples. Give it a push.

gravitymotor drive

Balanced.