Arduino Meets Lego: The Ultimate DIY Robotics Project

Cyrus Tabrizi, 8/29/13
      Now it’s time to hook up your batteries. This part is a balancing act (unless you have spare voltage regulators), because the Arduino and Servos operate at different voltages. The Arduino can be powered at voltages between 7 and 12 V (those are the recommended values) and has a built-in 5V regulator that you can tap into (and a 3.3 V one that the XBEE is running off). The servos should be running at voltages between 4.8 and 6 V. I found that 4.8 or 5V wasn’t providing the performance I wanted, so I needed a way to power them at 6V—not lower and not higher. The issue is this: if I want to use AA batteries, the theoretical outputs I can achieve are 4.5, 6, 7.5, 9 etc. (increments of 1.5V). If the main power source runs at 6V, I can power the servos directly from the batteries, but this is under the recommended 7V minimum of the Arduino. If I run everything at 7.5 volts, I will overheat the servos, but I will provide the Arduino with enough power. The trick, though, is that those 1.5V increments are the theoretical voltage of an additional AA battery. In reality, not even a brand new AA battery will run at 1.5 V (and rechargeable ones certainly will not either), so I should be expecting voltages lower than 6 and 7.5. The problem is that as I get closer to 6V, I’m also getting closer to 5V—this is a risk for the Arduino, which runs on 5V. If it doesn’t have enough input voltage to regulate out 5V, it will reset or turn off. If I were powering the Arduino with fresh batteries and not connecting those batteries to anything else, I could probably get away with running it at 6V. However, since I’m running the servos off the same batteries, any voltage drop caused by the servos (which can be caused by stalling) would cause the “6V” supply to drop down to levels possibly below 5V. Ideally, voltage regulators would be used with a 9V supply to power the servos and Arduino independently, but I’ve also had success running it off 5 rechargeable batteries, which, combined, provide between 6 and 7.5V.
      I just discussed using different combinations of AA batteries. To connect them, you’ll probably need a battery holder of some sort. Mine was a Lego Power Functions battery box and could hold up to 6 batteries. Since I only wanted 5 batteries, though, and I didn’t want to modify the battery box, I decided to make a fake battery from aluminum foil, a piece of Lego, and some tissues or paper towel. Rip off a piece of paper, wrap a 5-long Lego Technic beam with it to give it a nice round shape, and then wrap that with Aluminum foil. This should be long enough to connect the terminals that a AA battery would normally connect to.
      Now comes the cruelest part of all: modifying a Lego piece. I thought long and hard about alternatives, but, in the end, it just had to be done. The battery holder, being made for Legos, has a Lego wire connection for connecting motors and other Lego devices. To use this connection to power our RC car, though, we just want a positive and a negative wire. This means that you’ll have to cut a Lego Power Functions wire in half, and strip the wires on the outside down so that you can solder a usable solid-core wire to it (In my defense, I kept both halves so that I could put them back together once this project was over…). Since the battery box has a built-in polarity switch, you won’t necessarily know which wire is positive and which wire is negative—you’ll have to pick one direction, test it with a voltimeter, and hook it up to the breadboard appropriately. Do this with caution, because you don’t want to fry all your components! No pressure.
      The way I connected the battery was like this: hook up the battery’s positive connection to the same line that all the servos are connected to; connect the battery’s negative connection to the Arduino’s ground pin, and run a wire from the battery’s positive connection via the breadboard to the VIN pin on the Arduino (this is the voltage supply pin that feeds into the built-in voltage regulator). This way, all the grounds are shared, which needs to be so for everything to work.