Balancing robot with etched PCB shield

by JDD, published

Balancing robot with etched PCB shield by JDD Jun 23, 2012

Featured Thing!

1 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps


Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag


Thing Statistics

17842Views 2203Downloads Found in Robotics


Balancing robot with printed wheels and structural parts. It uses a Arduino Uno, accelerometer/gyroscope, and a etched motor/servo PCB shield that I made.

Here's a video of it in action

The final robot is quite a bit different from the first prototype. You can see the progression of this project here:

I've wanted to make a balancing robot for a while but I was always turned away by the cost of all the parts. I tried to avoid using any expensive electronics or motors and instead tried to use common parts that other might have lying around. This is pretty much my first arduino/programming/PCB project so I'm sure there is room for others to improve it. Using servos was a cheap alternative to much more expensive geared motors but they're also a bit slow. This means that the robot can only recover from small pushes.

The PCB was designed using Fritzing http://fritzing.org/ with help from http://www.fubarlabs.org and code is at http://github.com/jdorweiler/BalancingRobot

The board has the H-bridge, which can control two DC motors or one stepper motor, accelerometer/gyroscope, and two servo connections. The PCB isn't required but I did it for fun. The three iterations of the robot used a DC motor, stepper, and servo so I though it would be nice to make a board that can handle any of those.

I got a lot of the code and good information was found from

If your making the PCB and using a different accelerometer board, make sure to check the pins. They're probably not the same and the one I used. This would be easy to change in the Fritzing file though.


-Arduino Uno
-4x 15 to 20mm M3 bolts and nuts or similar to attach the servos
-2x continuous rotation servos http://www.adafruit.com/products/154
-Accelerometer/gyroscope board. Any will work. I used this one http://www.csgshop.com/product.php?id_product=64
-5/16 or 8mm round wooden rod (from any hardware store)
-PCB etching supplies if you are etching your own board. Otherwise just use a bread board.

Print 1x:
-Servo mount
-Arduino holder (I got this off thingiverse but can't find the page)
-Battery mount (this is just the arduino holder, stop printing before the arduino mounts start printing).

Print 2x:
-Wheels (made from http://www.thingiverse.com/thing:21486 )

Assembly is pretty easy. The wooden rods should be a tight fit through the square holes but if not a bit of hot glue helps keep them in place. Use some thin wire to attach the wheels to the servos.

Download the code and PCB files

Getting the robot to balance will still take a bit of work because of small differences in printed parts and servos. The main file in the Arduino sketch has a block of parameters to play with. These are the setpoint angle where the robot is balanced and the aggressive and conservative PID parameters. Its pretty much guess and check for those but I've left the ones that worked for me.

More from Robotics

view more

All Apps

3D Print your file with 3D Hubs, the world’s largest online marketplace for 3D printing services.

App Info Launch App

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

3D Print a wide range of designs with Treatstock. Easy to use tools to get the perfect result. The global 3D printing network that connects you with high-quality and fast working print services nea...

App Info Launch App

Is there any chance of sharing the circuit diagram please ?

JDD, i need your help.. i use your code in my balancing robot. but it didn't work appropriately. can i ask you, how long you made for this robot? can i have your email? to ask for help with my robot.

thank you

Thank you for sharing! buyincoins, where you can buy good products from China directly without any shipping fee.

Thank you for such a well presented project. I, like many have wanted to do a balancing robot but do not have the Arduino expertise yet...

Thanks Again JDD

Thanks! I tried to take good notes and keep things simple so that anyone can build it.

I would guess that I could do this with the board from my quad copter. It has the abillity to auto level the copter, so why not a robot?


Ill have to try it. thanks for the inspiration.

That board looks good. It says it has a servo out which you might be able to use for the motors too.

Great job JDD! I have a Crius SE board for quad copter and used it. Just had to change getting the sensor data. Foxdewayne, if you haven't done anything yet let me know and I'll send you the code.

It took a bit of fiddling with the tuning parameters.
I do have one problem that's driving me nuts. It'll all of a sudden start thinking it's over too far and the servos just stop. This happens every few seconds. It seems to be related to the Loop Timing. If I comment it out the servos don't stop.
Any ideas?