Hi!
You have managed to get line following function working. Thats good.
Now scale down the projekt into the balancing task. Just work with the balancing issue!
Robots balancing on, f ex 2 wheels, have already been made so there must be threads to find.