Controlling high power (or high number of) LED’s with an Arduino

A while ago I posted about my bench lights, and have gotten a number of request for schematics and code. I’ll gladly put the code up, but I also wanted to explain what I did so that others can create their own, or at least change my design up as they wish. The transistors I’m using are TIP122’s. You can find the data sheet here. They will switch a lot of power, but keep in mind, they need to have adequate cooling if you are going to push them hard. Always remember, fire = bad.

I covered the basic schematic for a few LED’s in the video above, but if you have any questions, feel free to post them in the comments and I will answer as quickly as I can.

You can download the original (controller with LCD and hard buttons) code here.

You can also download the newer (serial controlled – adjustable level) code here.

Just a note, I will be using Vimeo from now on, but I will still put all my videos on YouTube as well.

27 thoughts on “Controlling high power (or high number of) LED’s with an Arduino

  1. Pingback: Controlling high power (or high number of) LEDโ€™s with an Arduino « adafruit industries blog

  2. Pingback: Workbench Light Controller « adafruit industries blog

    • Ed you are entirely correct. I totally labeled those backwards and did not catch it, even when I spoke them. Thanks for bringing it to my attention!

  3. Hi,
    Great article, busy with my workbench right now, so I found some nice ideas here!

    A question, if I may, is it posable to show us, or by writing an article, about how you communicate between you projects and the iMac?
    Do you program your arduino or avr with your mac.
    What do you use to talk with your prpject? A self written app?
    I realy hope you will share this with us.

    Thanks in advance.

    • Thanks iAdawan! The bench controller I did a video on here has all local controls on the LED controller itself. I do all my programming in the Arduino IDE, then using an FTDI adapter, I program the ATmega328, and it runs on it’s own. Outside of writing and programming, the iMac has no relationship with the LED controller. You can use processing to interface between an Arduino and an iMac, but I don’t have any tutorials done yet. ๐Ÿ™‚ Hope this helps!

      • Thank you for your reply.

        I understands that your lightcontroller runs on his own, but what about your movie? At 2:13 you show a window where you type the led light level value, how did you connect that?
        Thats what I am curious of, maybe basic for you but that info is a good start for me or I may say us.
        Did you wrote a kind of terminal there?
        Is there a kind of reading loop that checks the usb port inside your arduino code?

        Btw I did look for the rxtx but it looks like its from an external site, but that site is gone.
        I do have a FTDI adapter, but its difficult to find sample code for osx communicating with the adapter and whats behind.
        Thanks again.

        • I’m sorry, I misunderstood the question, yes, at 2:13 I do control the level from my iMac. This is done with the built in serial monitor in the Arduino IDE while connected to the breadboard via an FTDI cable. That is different than my bench controller that runs independent, but you are giving me some motivation to upgrade. ๐Ÿ™‚

  4. Pingback: Electronics-Lab.com Blog » Blog Archive » Workbench Light Controller

  5. Hi Jeremy and all
    I am new to this forum and new to working with arduinos. They sound incredible little tools. I actually do not have an arduino yet. I plan to purchase one tomorrow but first can you please tell me if I can use any type of arduinos to do what you have done in this example? I would like to computer control 6 different groups of high power leds 4 x 1W LEDs per group. I want to try and controll them as you show on this video. Can you please help me first by telling me which type of arduino should I purchase and can I control it using Windows XP?
    Thank in advance.
    Nico

    • Hi Nico! For the example above, and thousands of others, an Arduino Uno will work great. Today, Adafruit has them for $25 here: http://www.adafruit.com/products/50 Thats a really good deal. The Uno will work great with Windows XP, and you have 6 PWM pins, so you can have full dimming on all 6 banks of 4 X 1 watt LED’s. Thanks for stopping by, let me know if you have any further questions!

  6. title=”Adding more PMW pins”>
    Jeremy:
    thanks for the link i placed the order. I can’t wait to see if i can make it work. I was wondering how did you control it from the mac or pc? Is there another component that i need to make it work from the computer. In other words I want to be able to use the computer to control the arduino, not just upload the sketch. Also if i want to add more groups of light say an additional 6 groups how would i add more PMW pins on the arduino uno? If there is another small board to add how will the sketch control it?
    Thanks in advance Jeremy.
    Nico.

    • Hi Nico, I’m glad you got your Arduino ordered! There is a USB port on the Arduino and this is how you upload sketches to it. This same port can be used to communicate with the Arduino via a serial terminal program, or other program. So the bottom line is you don’t need to buy anymore hardware, you will have everything you need to get started.
      As far as adding another 6 banks of PWM dimming, that would require another board or, more cost effective, a TLC5490 IC. The only problem is that that chip is common anode output. You could accomplish this with some transistors. I have some TLC5490’s on my bench right now. Sounds like a future post.. Happy building!

  7. Hi,
    I was wondering how you limit the current for the RGB Led. As far as i understood you are using 5v to power the led with no resistors.
    Wouldn’t you need to limit the current to 350mA or something? Because using 255 pwm would be like applying 5v directly to the led, wouldn’t it?

    • Hi Leon, you are right. I did not limit the current to the RGB LED. It was a quick setup and I did not put resistors in. You should not do this, but those LED’s can take a beating, and at the same time shave off hours of lifetime..
      Having said that, there was a max of 500mA supply coming from my USB port, and that’s why the LED did not go up in magic smoke. ๐Ÿ™‚

      • Aand i have to bother you again. In the video you said the LED has a common anode and therefore you control it threw the ground. TIP122 is a NPN transistor. I would have expected a PNP? Isn’t the NPN “the wrong way round”?

  8. Good question Leon, You could use a PNP, but you could also use an NPN to switch ground by connecting the anode of the device being switched to positive voltage, the cathode of the device being switched to the collector of the NPN, grounding the emitter of the NPN, and then connecting the base to the controlling voltage (positive). I had TIP122 transistors, so I used them because they are darlington type transistors and were nice for switching a 12V device with a 5V supply. ๐Ÿ™‚

  9. Hi Jeremi,
    since the last time I posted a question to you I have come a long way but still an even longer way to go. I have used your setup/scheme and got it to work. I also want to share with you some of my own attempts. I soldered together nine 700mA white LEDs with forward voltage of 3.6V and got it to work just perfectly once I removed the resistor between the power source and the LED’s anode. My 9 LEDs are being pushed close to their limit but with a flactuating current ~680mA and 620mA. I also want to share with that to keep that current from flactuating I hooked them up with a 700mA LED driver and it works great keeping the LEDs from suffering by the flactuating current, right at and consistently almost fixed at 640mA.
    But now Jeremy I have another question for you. I want to control my LEDs using some interface example Adobe Flash or Processing. I have downloaded your processing code but right out of the box I get a “Syntax error, maybe a missing ] character”. Any updates on the code? Or do you have any suggestions?
    As always thanks in advance for your help.
    Nico.

  10. Hi Alocin! I’m glad your projects are going well! The way I controlled the LED’s in the video was simply from the serial port of the Arduino, there is no Flash or Processing script running. If you download the example in the Arduino IDE, you can then open the serial monitor and control them form there. You can also use any serial program like CoolTerm or Hyper Terminal. Your running 6.3A of LED’s! ๐Ÿ™‚

  11. Hi Jeremi,
    I’m planning a project with 8x 1-3W RGB LEDs, which i want to control separately. Is that also possible with the schematic you draw at the end of your video with one constant current supply? If changes are necessary, what do I have to do?
    saland.

  12. Your web page and video is exactly what I’m looking for. I have a circuit using two seven segment LED modules and it’s apparently too much for the additional hardware attached to the Arduino Uno. With the modules disconnected, the circuit works as desired, but the modules draw too much power, although only by a small amount.

    The 7 segment modules are common cathode and I have a large collection of TIP125 units from a previous project that I’d like to use. I’m using a pair of 74HC595 shift registers through current limiting resistors to the segments, but figure I can wire the shift register pins directly to the TIP125s, unless you think that’s unwise. On the output side of the TIP125, I would have the current limiting resistor to the segments of the display module.

    I’ve found the pinouts and data sheet for the TIP125s but lack the knowledge to be confident of the connection.

    http://www.dz863.com/pinout-819620563-TIP125/

    With base, collector and emitter from left to right (head-on), would I have the “trigger” from the 74HC595 to the base? The polarity of the remaining two pins escape me.

    I’ll be using 12v external to drive both the Arduino and the power to the LEDs so the ground will be common, but I’ll have an external ground from the battery to the LED segments to be certain of the capacity of the circuit.

    Am I on the right track? Is this a working plan?

    thanks for your consideration

    fred

  13. I’ve done a bit more research and found that my TIP125s are not a good choice for my project. In the process, I’ve discovered a circuit using 2N3904 transistors. Relatively inexpensive and low power, but I need less than 50 ma per LED segment.
    http://www.ecs.umass.edu/ece/m5/tutorials/multiple_LEDs_tutorial.html

    Digikey shows a large variety of transistor specifications from which to choose, but I’m confused about one of the columns of specifications. I want to use the 12v battery that powers the Arduino when disconnected from the computer, so I figure I’ll need some form of 5v regulator. All the specifications reference mV with no indication of the supply voltage. Is this a factor with which I need not be concerned?

  14. Hey, I’m a bit confused. You said that you need a 1k resistor between the arduino and the TIP122, but what wattage is the resistor? Also, I noticed that the TIP122 is a slower switching transistor. I’m building a lightning simulator, and for the sudden flashes, wouldn’t I need a low voltage fast switching transistor? Thank you for your reply in advance.

    • Hi Andrew, the resistors between the Arduino and the TIP122’s are 1/4 watt resistors, but they could even be 1/8 watt.
      I switch the TIP122’s at 490Hz without any problems, the data sheet says it will switch at 500KHz allowing 2ยตS to switch. That should work fine for a lightning simulator.
      Another great alternative is the IRLB8721PbF N channel Mosfet. It’s made by International Rectifier and a high speed rated device. These will also control much more current at lower temperatures. ๐Ÿ™‚

Comments are closed.