This paper is to study the balance of two-wheeled robots by fuzzy control and PID control. Two-wheeled robots need extra control mechanism to reach the balance since the system itself is instable. This study plans to implement the related control circuit to a real two-wheeled robot model. By realizing the fuzzy control and the PID control into microcontroller the two-wheeled robot can still keep the balance even when the external interference is added. At first, use the three-axis accelerometer to measure the angle of the body, and an angle error value is generated. Then, through the fuzzy algorithm and the PID algorithm to output an appropriate PWM (Pulse-width modulation) duty to drive the motor, the two-wheeled robot reaches the balance. Finally, compare the balance efficiency and the efficiency of resisting the external interference of the fuzzy control and of the PID control. The experimental result of the two-wheeled mobile robot shows that the method proposed in this paper is feasible.