Before we begin, I want to mention that this article is about powering multiple LEDs at once from a single Arduino pin. If you wish to separately control each of the LED, an article on that matter will be available soon.
What you need:
- Arduino board
- Power supply (9V battery, etc), other than your Arduino’s 5V VCC pin.
- 1x LM7805 or anything that can supply/regulate 5V
- 1x NPN transistor. I’m using BC141 but any general purpose NPN will probably work.
- 1x 470 Ohm Resistor – or any resistor in this ballpark
- 10x LED – or as many as you want. Maximum number is Transitor current / LED current. Since this BC141 can handle 1A, in this case the maximum number would be 1 / 0.020 = 50
Short version – Multiple LEDs on 1 Arduino I/O pin
An Arduino I/O pin in OUTPUT mode can provide a maximum of 40 mA and the reccommended value is 20 mA.
A single Light Emitting Diode needs about 10-20mA to produce light. More info on LEDs here: Light Emitting Diodes – The Basics)
To be able to provide the 200mA that 10 LEDs in parallel need, a NPN transistor is used as a switch. Basically, our Arduino pin will do nothing else than to turn on the transistor, which will allow current to flow from your battery/power supply to the LEDs.
This breadboard configuration is a bit different than what you can see in the image at the top, but it does the same thing, the wires are just arranged so you can better see where everything goes.
There are 4 parts on this circuit:
- Arduino – provides signal
- Battery – provides power, enough juice to power all the LEDs
- NPN Transistor – acts as a switch, connecting the battery to the LEDs when turned on by the arduino
- Block of 10 LEDs connected in parallel, with a resistor that limits the current to 100mA, meaning 10mA per LED
The way this works is the following:
- Arduino pin goes HIGH to 5V
- The 5V turn the transistor fully ON
- The transistor, since it is ON, now the current can flow from the battery -> through the 30 Ohm limiting resistor -> through the LEDs -> through the transistor -> back to GND. The circuit is complete so the LEDs are ON.
Now when the Arduino pin goes LOW to 0V, the transistor is fully OFF, so it does not allow the current to pass from the battery, through the LEDs, through it and to GND, so the circuit is not complete, therefore the LEDs are OFF.
Another important thing is the 470 Ohm resistor. This is important because it limits the current that can flow from the Arduino through the transistor. This particular resistor limits the current to around 9mA, which is pretty safe to get out of an Arduino I/O pin.
The calculation is the following:
You have 5V from the Arduino pin. There are approx 0.7V on the transistor, between its base and emitter, therefore you are left with 4.3V on the resistor. This means that the current that flows through the resistor is:
4.3V / 46
70 Ohm = 0.009 A which is 9mA
In reality, you have a bit less than 5V coming from the Arduino, which means less voltage across the resistor, which means even lower current. The measurements that I took were close to 8mA.
Now you know how to use a simple NPN transistor to turn on or off a bunch of LEDs, or anything else that you want. Have fun with your projects.
There are some limitations, as mentioned earlier.
- The current that your battery can provide has to be enough to power all the LEDs. For example, a standard 9V battery can provide around 500mA. Rechargeable batteries can provide much more. For example, Samsung’s INR18650 can provide up to 23A for continous discharge. This means 23000/20 = 1150 LEDs at full power. Now that’s a lot of leds. There are some tech specs on this battery here: http://www.samsungsdi.com/lithium-ion-battery/power-devices/power-tool.html
- Another limitation is on your voltage regulator. For example, LM7805 can output up to 1.5A. LM7805 is a linear regulator and it is not a good idea to put them in parallel to get more current. So basically you can’t use 2 of these in parallel to get 3A. There are however possiblities. You can either use a transistor or a buck regulator for more output power. The datasheet for LM7805 is available at the following link: https://www.sparkfun.com/datasheets/Components/LM7805.pdf
Another thing you could do to light up more LEDs even with a standard 9V battery is to get rid of the voltage regulator and just directly use the 9V to power the LEDs. This way you can put more blocks of parallel leds in series so that your circuit drops the whole 9V of the battery.
An example would be the following:
1 block of LEDs can use at most 500mA, because that’s what the battery can provide. This means that 1 block can have at most 500mA / 20mA = 25 LEDs
1 block of LEDs also drops 2V, so in series you can have 4 blocks which will drop a total of 8V, still requiring the same 500mA. This means a total of 25x4 = 100LEDs.
For this to work, you’ll need to calculate the following resistor like this:
9V (on the battery) – 8V (on the LEDs) = 1V (Remaining on the resistor)
1V / 0.500 A = 2Ohm
You can build the 2Ohm using multiple resistors in parallel, for better heat dissipation.
Now you can have 100LEDs lit up from a single 9V battery and turned on or off by a single I/O pin on the Arduino.
The transistor part of the circuit
This is how the NPN transistor part of the circuit works. In the image, the green graph shows the current that flows from the Arduino pin to the transistor, and you can observe that it is very low and is depended on the base resistor (200 Ohm in this image).
This small current represented by the green line turns on or off a much higher current represented by the violet line. This high current passes through the load, represented in this image by the 17 Ohm resistor, and this resistor is there as a placeholder for the LED block that is discussed in this article.
In the image, the values of the resistors are just picked almost at random just to illustrate how this actually works.