Balancing on two wheels is really really hard. It's slightly easier if you make the robot with a center of gravity below the axles, in which case it will tend to self-balance -- but that's probably not the goal of your exercise.
The algorithm is to use an accellerometer to sense the attitude of the robot, and then move the wheels to restore an upright attitude. But none of these things are trivial. And I doubt a BS2 has the speed, without a lot of work and testing, to achieve this.
Comments
I would recommend visiting the Lego NXT Support Forums for help on using their product.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
The algorithm is to use an accellerometer to sense the attitude of the robot, and then move the wheels to restore an upright attitude. But none of these things are trivial. And I doubt a BS2 has the speed, without a lot of work and testing, to achieve this.