self balance robot code for dead spot help needed

I have not done self balance robot ,and I want to do one too.
Here is a suggestion that may be helpful.

use a angle sensor to get the angle and then to conctrol the speed and direction of DC motor.
after a certain time and do the upper processing again.
If do with this method ,I think that maybe it can run forward at a certain angle and certain speed.

hope you can finish soon and share you control code.