Building and Connecting the Circuit

There are a variety of ways to connect components when you build a circuit. The most common practice, especially during the prototyping phase, is to use a solderless breadboard. As you build your circuit, you will need to power it, and with power comes the need to manage power fluctuations. This appendix explains the basics of breadboarding and offers some tips on working with power supplies.

Connecting and Using External Power Supplies and Batteries

The Arduino can be powered from an external power source rather than through the USB lead. You may need more current than the USB connection can provide (the maximum USB current is 500 mA; some USB hubs only supply 100 mA), or you may want to run the board without connection to the computer after the sketch is uploaded.

The Arduino Uno board has a socket for connecting external power. This can be an AC-powered power supply or a battery pack.

If you are using an AC power supply, you need one that produces a DC voltage between 7 and 12 volts. Choose a power supply that provides at least as much current as you need (there is no problem in using a power supply with a higher current than you need). Wall wart–style power supplies come in two broad types: regulated and unregulated. A regulated power supply has a circuit that maintains the specified voltage, and this is a good choice to use with Arduino. An unregulated power supply will produce a higher voltage when run at a lower current and can sometimes produce twice the rated voltage when driving low-current devices such as Arduino. Voltages higher than 12 volts can overheat the regulator on the Arduino, and this can cause intermittent operation or even damage the board.

Battery voltage should also be in the range of 7 to 12 volts. Battery current is rated in mAh (the amount of milliamperes the battery can supply in one hour). A battery with a rating of 500 mAh (a typical alkaline 9V battery) should last around 20 hours with an Arduino board drawing 25 mAh. If your project draws 50 mA, the battery life will be halved, to around 10 hours. How much current your board uses depends mostly on the devices (such as LEDs and other external components) that you use. Bear in mind that the Uno board is designed to be easy to use and robust, but it is not optimized for low power use with a battery. See Recipe 18.10 for advice on reducing battery drain.

The positive (+) connection from the power supply should be connected to the center pin of the Arduino power plug. If you connect it the wrong way around on an Uno or Mega, the board will not break, but it will not work until the connection is reversed. These boards automatically detect that an external power supply is connected and use that to power the board. You can still have the USB lead plugged in, so serial communication and code uploading will still work.