Arduino 101 Self Balancing Robot

Hi guys,

Really need some help/advice here. I built a 2 wheels self-balancing robot. The hardware is done as attached. The only problem is to make it balance. I loaded the code in Arduino 101 (As attached), with the correct initial position, it will be able to balance for a while and then keep moving forward and fall off. I aint sure how to make it just move within the range where it can balance itself. It always seems to me it will move forward /backward whenever out of the range.

Can anyone help to look whats wrong with my code ?

Thanks and appreciate :slight_smile:

Genuino101BalacingRobot.zip (4.46 KB)

Hello,

Cool project. I want build my robot at the weekend. That blue piece is 3d printed ? Can you share STL file.
Thanks.

The code includes a PID calculation, and you need to properly tune the PID constants for every new robot. Google "PID tuning" for tutorials.

Vincent, I'm curious as to what you are using to drive the motors. i have the same set motors and could not seem to get the 101 to drive then even with a Seeed Studio motor controller. An Uno had no problem though.