Here's a good starting point.

http://www.wa4dsy.net/robot/balancing-r ... ancing-bot