Some time ago I found a video series on how to program robots right here on programming robots, and I decided to try and make one named wheely bot. This is its story.
The first version was pretty simple. I ordered a simple body for it off of the Internet, as well as a motor controller circuit, and two wheel encoders. I used an Arduino uno that I already had laying around and programmed it to rotate itself and adjust its angle based off of what the angle of the wheels were. It knew what the angles of its wheels were based off of the wheel encoders, and it used a PID controller to adjust itself.
Unlike my previous attempts at robots this one didn’t just assume that the wheels had rotated by exactly what it told them to rotate by. Unfortunately there was a lot of wiring going to the Arduino and it began to become a little bit too much. To resolve this I tried buying some small breadboards to attach to the body, and put an Arduino Nano on them to help the Uno and reduce the wiring.
The idea was pretty simple: the Nano would gather sensor data, and use it to figure out what was going on, and the uno would control things and ask the Nano what was going on via I2C. This worked, but I still had a problem that had plagued the robot from the beginning: the wheel encoders weren’t very accurate. They were always up to ten degrees off from what the actual angle of the wheels were.
To fix this I tried getting four sonars, and decided to attach two to each side, and I came up with a math formula that would allow me to figure out what its angle to the wall was given the distances that the sonars were returning. This way it could find a wall and try to adjust itself.
I had even come up with a library for automagically calculating the accuracy of a given number that I got from a calculation.
It was around this time that tragedy struck. I had been using a two rechargeable double A batteries, and a 9v battery to power it because the motor driver need 12 volts to operate, however everything else needed 5 volts, so I had been using a 5v regulator. Unfortunately everything was drawing a lot of current, and that caused the regulator to break, and, weirdly enough, put out more than 5 volts. This fried basically everything.
After some panic over losing potentially everything, I bought two new arduinos, and they broke as well. So I tried buying a DC to DC converter which could offer more current, and not break as easily as well as get some 6v rechargeable batteries that could offer more current.
Since I was tight on money I decided to use a raspberry pi zero that I had laying around as the control brain, and use the new Arduino Uno that I had as the sensor brain/motor controller.
Since programming a raspberry pi zero is different than programming an Arduino I have not yet been able to get all of my original code (located here) to work yet, but I have however added a new feature: unlike the previous wheely bot, the new one has a USB Wi-Fi adapter that connects to my home network, and allows me to remotely login to it, and remote control it.
I’ve finally gotten the remote control program working, as well as the on board camera that I had added to the raspberry pi zero. Now I finally have a remote control toy with an onboard camera like I’ve always wanted as a kid.
You can find the new and improved Wheely bot source codes (“codes” because there’s more than one program) here ,here, and here.
There’s also a youtube video: here