If I have an Arduino Mega, can I supply power to that using a 9V battery?
I heard something about a 9V battery charger given with Arduino. Is this true? Can I charge a rechargeable 9V with arduino?
Thanks a lot!
Yes, you can run an Arduino MEGA with a 9V battery. Hook it to Ground (-) and Vin (+) or hook it to the power connector (barrel = -, center pin = +).
A 9V 'transistor' battery will only last a few hours. A set of 6 AA batteries will last much longer.
The Arduino does not include a battery charger. It is possible that you can connect the Arduino to a 9V rechargeable battery that is also connected to a battery charger. I don't know how well that works.
Nice. I'll buy a set of 6AA batteries. Is there a suggested amperage or I can buy whatever batteries I want?
Get NiMH rechargeable AA-cells, then you can recharge them over and over. They come
with 2200-2500 mAhr energy ratings nowadays. OTOH, for desktop use, all you need is
a 9V wallwart.
You can also just use 3 AA batteries connected to 5V/Gnd header pins, bypassing the regulator. Put a diode from 5V pin to Vin pin so the regulator is not reverse biased.
Batteries are rated in Amp-Hours, small batteries in milliamp-hours. A battery rated at 1000 mAhr will run 1000 hours at 1 mA, or 10 hours at 100mA, etc. But of course, battery voltage doesn't suddenly "run dry" like a fuel tank in a car. The voltage strats droping-off as soon as you drain some current from it. So, the useful life of the battery depends on how low the voltage drops before your device quits working, or quits working usefully.
The amount of current consumed by your Arduino circuit depends on what you've got connected to it, and what other circuitry, LEDs/lights, motors, etc. that you are running. If you want to predict how long the batteries will last, you will most-likely have to measure the current consumed by your particular circuit (or make an estimate based on the components used).
Rechargeable batteries are usually marked with the mAhr rating, but for standard non-rechargable Alkaline batteries, you'll have to search the web for the manufacturer's data sheet.