It seemed a straight-forward proposition last night when my nephew and I were wondering how to run the Arduino without being connected to the laptop. I must confess there was a point in our internet search where I wondered whether it was possible at all.
So then I went to ladyada.net and found this Arduino Tutorial – Lesson 0: Getting Prepared. It states near the bottom: “Another way to power up the Arduino is to plug in a battery or wall adapter into the DC jack.”
Just so we’re clear, the DC jack is this here:
Adafruit continues: “Verify that you have a 9V DC 100-500mA power adapter, with a 2.1mm barrel plug and positive tip. If the box doesn’t have any information about the adapter, you can look for these clues” — whereupon it shows the information that should be printed on the adapter.
Just now I inspected one of the half dozen or so of the Mystery Power Adapters that my apartment seems to collect in lieu of stray cats, and the symbol is reversed from the one in the Adafruit example, with the plus on the left and the minus on the right, but the minus is still on the outside and the plus inside, and that’s what matters.
My Mystery Adapter outputs 400 mA, which is okay for current, but only 5.2V DC, which may not be enough to power the Arduino. I suppose I could test. After all, low voltage never damaged a circuit. He said.
Anyhow, according to Adafruit, a 9V power supply can be handily obtained at Radio Shack for about ten bucks, and that’s probably the safest bet. But I’m sure Goodwill has bins brimming with orphan power supplies that might inexpensively fill the bill for a more daring soul.
So onto the question of battery power. Along the way in my voyage of electrical (electronic? electronical?) discovery, I asked the question, “Well, how much current can a 9v battery deliver?” That was answered here. I’m reading the charts to say that with the Arduino as the load, you can get about 3-5 hours off a 9 volt battery.
The next question is, how do you plug your battery into the DC power jack? Well, SparkFun has a 9V-to-barrel-jack adapter (PRT-09518) that is specifically identified as good for the Arduino. It only costs $2.95, so there you go. Link is here.
And finally, you can just stick the leads of a 9V battery snap connector into Vin and a GND (why not the one next to Vin?), like so:
The use of Vin is explained at the Arduino site here.
The wires of this particular Radio Shack connector (270-0324) shown in the photo are braided and despite efforts to avoid it, tend to bend into shapes that don’t want to go into the holes anymore. Since you may be wanting to insert and retract the positive lead a lot in order to turn the Arduino on and off, it might be best to stick the snap connector leads into a breadboard, then use a solid-wire jumper to go from the breadboard to the Arduino. Or, you could solder a bit of solid wire (and maybe also even a switch) to the positive lead. I suppose in the short run a paper clip will make do in order to attach a jumper to the lead in the event that you don’t want to reach for the soldering iron just yet.
So what have we learned? We learned that we can program the Arduino to do all sorts of things, and then we can disconnect the board from our laptop and send it into the great world to do those things on a DC Power supply or, even more independently, a 9V battery. I’ll claim that I already knew this (though my faith was shaken), but it’s good to know what the numbers are and where the links are.
(NOTE: This entry was updated 14 October 2011 to add info on the use of a battery snap connector.)