BaBot ball balancing robot
By Andrew Gregory. Posted

Have you ever seen a robot that can play catch? Well now you have. This is BaBot – a fully open-source robot built by architecture student Johan Link. And it’s absolutely ingenious – there’s no camera here to keep track of the ball, as you might think at first glance. Instead it uses a matrix of infrared LEDs and phototransistors to detect the position of the ball. The LEDs emit light, and the phototransistors measure what’s being reflected – in a way, Johan has created a very simple version of an eye, with the photoresistors standing in for the cells in the retina.
Advertisement
The desktop computer you've been waiting for: Raspberry Pi 500+
The ball location data is sent to an ATmega32U4 microcontroller (the kind that’s also used in the Arduino Leonardo), which controls three servos attached to simple mechanical linkages that connect via magnets to the top plate; this adjusts the position of the top part of the robot, balancing the ball on the acrylic plate on top, and creating a continual feedback loop between the ball, plate, sensors, and servos.
You can just about make it out in the photos, but the joints between the top half of the robot and top of the mechanical arms are metal balls and magnets; this gives the joint smoothness and ensures no loss of contact to mess with the algorithm’s calculations.

BaBot isn’t a new idea: Johan made the first version as a high school project in 2018, when videos of it went viral on Instagram. The version you see here represents years of passion, ingenuity, and hard work. “I wanted to create something that brings abstract engineering concepts to life,” Johan tells us. “BaBot is a great way to teach and explore robotics, mechatronics, and control systems, but beyond that, it’s simply fun to watch and interact with. I believe that hands-on, physical systems like this offer some of the most effective learning experiences.”
The first version of BaBot used an overhead camera to monitor the ball, which required much more processing power; using LEDs and photoresistors has enabled the use of a much smaller controller, but it did give Johan a headache when it came to dealing with ambient light.

The robotic balancing act is powered by a 5V, 10A DC power supply, as well as what Johan describes as a “classic PID algorithm”.
The microcontroller processes the data using the PID (Proportional-Integral-Derivative) algorithm, which works out the difference between the ball’s current position and the desired target position (typically the centre of the plate). It then calculates the correct angles for each of the servos; the plate’s orientation changes, and the process repeats approximately 30 times per second to keep the ball perfectly balanced.
If you fancy building your own ball balancing robot you can buy the kit from Johan at ba-bot.com; alternatively, you can make your own with a 3D printer, laser cutter, and Johan’s bill of materials.

Features Editor Andrew trawls the internet for Cool Stuff while keeping the magazine running smoothly.
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles

Raspberry Pi 500+ in Raspberry Pi Official Magazine issue 158
We’re quite taken with Raspberry Pi 500+. But when you don’t need all that processing power, and just want a board that will make a plastic skeleton jump around in a terrifying manner, you’ll find Raspberry Pi Pico more than up to the job. There’s more terror in the magazine (which is only right as […]
Read more →

Win one of five Raspberry Pi SSD 1TB
Raspberry Pi prides itself on high quality hardware, and this 1TB Raspberry Pi SSD is no different. You can use it with a standard Raspberry Pi or even in your desktop PC – the choice is yours. We have five to give away and you can enter below Win 1 of 5 Raspberry Pi SSD […]
Read more →

Dual-screen cyberdeck
Twin screens mean you can code on one screen while watching David Bowie’s 1978 Musikladen show on the other.
Read more →
Sign up to the newsletter
Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.