While there are a couple of open-source brushless drivers already available, [neuromancer2701] created his own brushless motor controller on an Arduino ... design and source code are available ...
Getting a robot to stand on two wheels without tipping over involves a challenging dance with the laws of physics.