If you're into LEGO Mindstorms and sensors for them, the source code that runs a Segway-like 'droid is freely available. :)
Shared publicly