This paper studies the control of a two-wheeled vehicle which is similar to an inverted pendulum system and has hand sensors to make right and left turns. Because the two-wheeled vehicle is unstable and its load is uncertain, PID and LQR controllers are used to stabilize the uncertain and unstable plant. Moreover, the two controllers can make it move forwards and backwards, and turn left and right. The two controllers are implemented into a microcontroller, and the microcontroller outputs appropriate control signals to drive the two-wheeled vehicle according to the three-axis accelerometer and gyroscope sensors. Finally, we verify the controllers' efficiency and compare the difference between above two controllers.