This is the control code for a robot I made with the Lego WeDo robot kit. You hold it by the bottom, and when you tilt your hand left or right, it moves itself so the platform stays level. You can see a video of it in action here: https://vimeo.com/133270115 Photos showing how I made it are included as backgrounds.
A Komaba original