Hi me and a friend is making a computer shelf with leds in the woodwork, were using a special glue for the plexiglass in the shelf which means we're using individual rgb leds, four leds for each window (3 windows) and what I need help with is, amount of voltage, ampere, code and how to connect all this up. I've used 123d.io to sketch something up but I'm struggling with getting proper strength in the leds.


(code https://puu.sh/lI6PC/e214028b07.txt)

Aswell as some of them change colors as the picture here shows: On

I'm very new at these things so I really appreciate all help and advice (and from an earlier post, reason for not using strips is purely based on the method of build, the shelf will not sit correct if the strips were in use)

  • What do you mean by proper strength in the leds. The second image seems to indicate you are running the leds at only 1mA. 20mA is generally the current to run an led at, to get maximum brightness. – Gerben Dec 3 '15 at 19:59
  • Also using 12v as a supply is way more that what's needed, resulting in more losses. – Gerben Dec 3 '15 at 20:01
  • How do I calculate to get which voltage is needed, I thought it was just mostly multiplying 3V per led then sum it up and done deal, but as I've seen it's completely wrong so how big is the needed powersupply? – Henrik Dec 3 '15 at 20:28
  • That what you need to do if you connect them in series, but you are connecting them in parallel. So you need a voltage higher that the forward voltage of the blue led, which is about 3.2V. You need about 720mA when you turn on every led (at 20mA). – Gerben Dec 4 '15 at 13:43

It's not advised to connect leds in parallel, with only one common resistor. Slight difference in forward voltage of the leds will create big current differences. This will make some leds appear brighter that neighboring leds. It can also damage the brighter led since too much current can flow through them. So you need to add a resistor to each led, and common the other side of these resistors to the transistor.

Second bigger error is that there isn't any resistor between the arduino pin and the base of the transistor. Without it there is nothing limiting the current going into the base, which could fry the arduino pin.

  • Thank you, I'll add that :) is the ones I'm using decent (270ohm) – Henrik Dec 3 '15 at 20:12
  • 270 will work, but isn't ideal. I'd use something like 2k. Lower values will be less efficient, and make the transistor run hotter. You could put a few 270 resistors in series to create a higher value resistance. – Gerben Dec 4 '15 at 13:47

There's a lot to unpack here, this is actually several questions.

First of all, the way your circuit is designed currently, your data pins are connected via the transistors to ground. This means if you set a pin high, or use analogWrite(), the Arduino will pump as much current as it can get, directly into the ground. This can damage the Arduino. Put a resistor between the pin, and the transistor.

The first point is that you are using several LEDs. If you want to control them separately, you will need 3 pins per colour. AnalogWrite() only works on PWM pins - if you look at your Uno, you can see that some of the pins are marked with a ~ (pin 3,45,6,9,10,11) - these are the only ones you can (easily) use. Since there are 6 of them, you could only run 2 LEDs this way. You could either run the project on multiple arduinos (1 Arduino per 2 "windows"), or you can get a chip to do the heavy lifting for you. I am working on a similar project, and am using a TLC5940 - there is a thorough tutorial at http://playground.arduino.cc/Learning/TLC5940 - they also save you from having all the resistors and transistors, and each TLC5940 will run up to 16 LED-pins (3 per LED, so you can run up to 5 "windows"). They are also designed to daisy chain, so if you need more, you can just add another chip; no extra Arduino pins to worry about. 3 of them can run all 12 of your LEDs independently.

The next item to be aware of is that there is a limit to how much power (in Amps, or milliAmps) you can draw from a given power source. Each part will use a certain number of millAmps. The spec sheet for your parts should tell you how many. LEDs are generally around 20mA (per colour), but this varies - check the datasheet. An Arduino uses about 50mA. This means that if all 12 of your LEDs are bright white, you will be drawing 50mA+(20mA * 12 * 3) = 770mA.

How does this affect you? Well, if your project draws less than the power source can provide, you're golden! You can't provide "too much current" to a component - it will draw what it needs. When you draw more than the supply can supply, you get one of two results. If it runs on the mains, it will overheat, and eventually either burn out, or catch fire (there are exceptions to this, but you'd better be sure of your facts before risking it!). How long this takes, depends on how much current you are drawing, and how much margin there is on the power supply. In the case of a battery, the battery will drop in voltage, and will also heat up (but is much less likely to catch fire). I suspect this is happening here. If you have a multimeter, you can hook up your circuit to batteries, and then measure the voltage between + and - on the batteries.

P.S - +1 to @Gerben - you need one resistor per LED leg (except common). If you use the TLC5940, you would need 3 TLC5940s; as I said before, you can daisy-chain them. This does, however, mean that you can control each LED individually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.