← All articles

17 November 2026

How a Balancing Robot Stands on Two Wheels

Illustration of a two-wheeled robot balancing, with a gyroscope sensor and a control loop

Picture your child watching a robot with only two wheels, a tall thin body, standing upright in the middle of the room without falling over. No kickstand, no string, nobody holding it. It wobbles a little, then steadies itself. It looks like magic — but it is actually one of the classic and most beautiful problems in robotics: balancing an inverted pendulum.

Self-balancing two-wheeled robots are everywhere: Segways carrying people around, delivery robots rolling through warehouses, one-wheeled electric vehicles, and the robot toys children love. They all share one principle, and that principle is simple enough for an 8-year-old to grasp — and deep enough for engineers to spend whole careers on.

The inverted pendulum: standing still is unstable

Try an experiment at home right now: balance a pencil upright on your fingertip. How long does it stay? A fraction of a second, then it falls. That is because the pencil's centre of mass sits above its pivot point. The tiniest lean makes gravity pull it further in the same direction — the more it leans, the faster it leans. Engineers call this an inverted pendulum, the opposite of a clock pendulum, which hangs its mass below the pivot and swings back to balance on its own.

A two-wheeled robot is an inverted pendulum: a tall body with its centre of mass above the wheel axle. Standing still is physically unstable — there is no mechanical trick that makes it stand on its own. The only thing holding it up is software: a loop that measures and corrects, hundreds of times every second.

The good news is your child already knows how to do this with their own body. Ask them to balance a broom on their palm: when the broom leans forward, the hand must run forward, getting underneath the falling head of the broom. The robot does exactly the same thing — only with wheels, and far faster than any human hand.

The robot's inner ear: the IMU motion sensor

To correct an error, the robot first has to know how far it is leaning, and in which direction. That job belongs to a small chip called an IMU (inertial measurement unit), often an MPU6050, which packs two sensors into one:

Neither sensor is good enough on its own. The engineer's solution is elegant: blend the two signals with a formula called a complementary filter. In plain words: trust the gyroscope in the short term, because it is fast and smooth; let the accelerometer pull the estimate back toward the truth in the long term, because it never drifts. One line of maths, and two weak sensors combine into one trustworthy answer.

This is the first big lesson a balancing robot teaches children: in engineering, there is rarely a perfect sensor. A good engineer does not hunt for a perfect sensor — they combine several imperfect sources of information to make a good decision.

The PID loop: three letters that hold the robot up

Once the tilt angle is known, the robot has to decide how hard to drive the wheels. That decision formula is called PID — three parts added together:

The loop runs non-stop: measure the angle, compute the motor command, drive the wheels, measure again. A good loop runs about 100 times per second — every 10 milliseconds the robot "looks" once and corrects once. Any slower, and the robot falls before it can correct. Much faster, and it burns computing power without doing much better.

And here is the subtlest point, the one beginners most often get wrong: the wheels must accelerate toward the side the robot is falling, not just drive at a speed proportional to the lean. To stop something falling forward, you have to move its support forward, getting it back under the centre of mass. Driving at a steady speed cannot save it — only acceleration brings the wheels back underneath the tipping body. That is also why the hand balancing the broom has to jerk sideways rather than slide smoothly.

Why this robot is a wonderful lesson for kids

A balancing robot packs almost all of robotics into one small project: sensing (the IMU), computing (the filter and the PID loop), and acting (the motors). Your child does not just learn one concept — they learn how the three parts talk to each other in a closed loop: measure, decide, act, measure again. That is the same loop every robot in the world runs, from a vacuum cleaner to a self-driving car.

It also teaches a very engineering attitude: failure is data. The first time the robot falls is completely normal. The engineer turns the P gain up a little, adds D to calm the wobble, and tries again. Every fall tells you where the loop is wrong. Children learn that "it doesn't work yet" is not failure — it is one step in the process of making something that works.

Try it with your child today

Start today, no kit needed

Your child can start exploring the sense — decide — act loop today on ManuStem — a browser-based robotics platform, no kit required, for ages 8+, with 28 lessons including 8 Component Lab lessons and 20 Competition Robot lessons, 4 of them free to try. The built-in AI co-pilot helps your child wire circuits, write code, and debug step by step, and the 3D robot preview shows their creation before it runs. Start at stem.manusignal.com — in Vietnamese or English, whichever your child prefers.

Read the Vietnamese version:

Robot giữ thăng bằng: vì sao robot hai bánh không ngã