User Tools

Site Tools


Tilda - A two-wheel balancing robot using Lego, Attiny, Raspberry Pi


Tilda is a self-balancing two-wheel Lego robot with Raspberry Pi as I2C master. IMU used is an MPU-6050, plus a HMC5883L magnetometer for absolute direction. Motors are Lego 71427, driven by an SN754410 dual H-bridge, controlled by an Attiny861 I2C slave as PWM generator and for back-EMF and battery voltage measurement. Power is provided by a reused 2Ah 9.6V NiCd rechargeable battery pack.

Tilda in action

The high pitch sound on the videos stems from the PWM signal modulated at 2000Hz in this version. I've now made some torque measurements (see here), according to which low speed torque is in fact better at higher frequencies, and have switched to a default of 16kHz.


Click here for the Fritzing file.


Source code

The complete source code is available for your consideration at

en/tilda.txt · Last modified: 2014/06/05 23:39 by sebastian