If you haven’t seen Lauren’s self-balancing robot then go over to robotsquare.com for this cool project. It uses the 31313 set with the addition of either a lego gyro sensor or the Hitechnic nxt gyroscope. It is easy to build, although the program is quite complex, but Laurens gives links to two technical articles which help with understanding it.
While you are at it, his new book The Lego Mindstorms ev3 Discovery Book is also well worth getting hold of.
Amazon sell it or from the publishers www.nostarch.com I have been working through it and it is excellent.