This paper presents a mathematical modeling and simulation of a two-wheeled self-balancing robot using a linear quadratic regulator (LQR) controller. The authors analyze the robot's dynamics and demonstrate the effectiveness of the LQR controller through MATLAB/Simulink simulations, highlighting its ability to stabilize the robot's pitch and heading angles under various conditions. Results indicate that the controller successfully manages the robot's balance, achieving desired performance metrics such as settling time and steady-state error.