Using in a PC case, Powering more than 5v of LEDs.

I've got a small lighting project I'd like to do, and I'm very new to electronics. However I have a friend who is helping me, and he better understands all the terminology, so don't be afraid to say what you mean!

I'm trying to mod my computer case to have a few RGB LEDs in there. The specs for the LEDs are as follows:

Size (mm): 5mm Round
Lens Color: DIFFUSED
Reverse Current (uA): <=30
Life Rating: 100,000 Hours
Viewing Angle: 30 ~ 40 Degrees
Absolute Maximum Ratings (Ta=25°C)
Max Power Dissipation: 80mw
Max Current Per Color: 20mA
Max Continuous Total Forward Current: 25mA
Max Peak Forward Current: 75mA
Voltage: Red - 2.0v // Green/Blue 3.0-3.4v
Reverse Voltage: 5~6V

That makes a little sense to me.

I'd like to have about 10LEDs in the case, and then be able to use 3 Potentiometers to control the R,G and B values via PWM. The Arduino is capable of this...

However in a computer case, I get the option of 5v, or 12v to power the Arduino,and the LEDs. I'm not sure if my PSU outputs AC or DC... I believe the Arduino needs DC, correct me if I am wrong please.

So let's assume I would like to light all the LEDs to create a pseudo white light. That means red would be using 2v, and blue and green would use 3.4 respectively. So one single LED would use 8.8v, and 60mA, correct?

Aside from not quite knowing how to get power from inside the case to the Arduino, I also don't know how I can power 8.8v from only a 5v output that I believe the Arduino is limited to.

Initially I was planning to just use 3 pots to regulate voltage and dim the LEDs that way... But then I learned about current and realized that some LEDs would end up brighter, or turn off before others... Hence the need for PWM, and an Arduino, unless someone has a better idea, and I am going totally off the wall!

I'd appreciate any advice, thoughts, or insight! Thanks for you're time!

The PSU in a PC only supplies DC.

It usually makes 12v, 5v,3.3v and -12v available, although 3.3 is probably only fed into the main 20-pin plug for the motherboard.

You can feed your Arduino directly from the USB headers instead of a real USB socket if you like.

Also, the 3 leds inside each unit will be wired in parallel, so you add the current, not the voltage.

I guess that leaves me with only one question! How do I provide 12v of power to the LEDs, and still be able to PWM them with out blowing up the Arduino?

Also, since I really only need a PWM controller... Perhaps there is a better method than an Arduino? As I've got this other project that might be more suited to one.

The easiest way is to use the 5v from the PSU to feed the arduino and the ledS. You could feed the LEDs through a suitable resistance (300 ohms is a good start) directly from a PWM pin to each colour of the RGB LEDs. kind of depends how many 'a few' is

I had about 7 to 10 LEDs in mind.

It could be done with a single Arduino (or a simpler Arduino substitute like the RBBB ) without any fancy switching gear if you could live with the LEds not being full brightness. If you fed 2 groups of 5 LEDs from 6 PWM pins with a 1K resistor to each colour of each LED. It would keep the current through each pin to a level where it would't cook anything. A full arduino isn;t very cost effective, much cheaper to use a bootloaded ATmega chip on a lump of stripboard or something., since the USB and power supply probaly isn't needed. The 5V from the computer PSU is good enough to feed the chip direct.

Not LEDS but heres a cheap stripboard 'Arduino' I did a while back.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1260399444

You could use a full Arduino to develop the code and then swap chips onto the strip board for the finished project.

In theory, if I took an ATmega168 with an Arduino boot loader, a 16MHz crystal, then gave it 12v... I shouldn't have any problems... My only issue is that I don't know where to get it connected to a serial/USB port, or how to hook up pins...

I'm really new to this stuff, but I've learned a lot over the past few days... Many nights of going to sleep at 3-5am... It's crazy, but I found I am really into this!

This might help with running 10? LEDs off one board. I think there's a version around for RGB LEDs but you'll need to search the forums.

It's an explanation how to light up 16 LEDs using 2 74HC595's while only using the power for 8 LEDs - all from 1 Arduino and 5 volts.

It's necessary to read this tutorial first:

There's code examples that explain how to start off with 1 register, then 2.

The key to lighting up all 16 LEDs, while really only having 8 on at a time, is this loop:

  digitalWrite(latchPin, 0); // ground the latchpin
  shiftOut(dataPin, clockPin, 255); // 1st register ignite all 8 LEDs
  shiftOut(dataPin, clockPin, 0);    // 2nd register turns off all 8 LEDs
  digitalWrite(latchPin, 1); // return the latch pin high

  digitalWrite(latchPin, 0); // ground the latchpin
  shiftOut(dataPin, clockPin, 0); // 1st register turns off all 8 LEDs
  shiftOut(dataPin, clockPin, 255);    // 2nd register ignite all 8 LEDs
  digitalWrite(latchPin, 1); // return the latch pin high

Because of the speed, the human eye will only see 16 LEDs turned on, while really there is only power going to 8 LEDs. Adding extra 74HC595's to expand on the number of LEDs, while still only having 8 LEDs powered at any one time (thus not blowing up the Arduino), is done per:

  digitalWrite(latchPin, 0); // ground the latchpin
  shiftOut(dataPin, clockPin, 255); // 8 on
  shiftOut(dataPin, clockPin, 0);    // 8 off
  shiftOut(dataPin, clockPin, 0);    // 8 off
  shiftOut(dataPin, clockPin, 0);    // 8 off
  digitalWrite(latchPin, 1); // return the latch pin high

  digitalWrite(latchPin, 0); // ground the latchpin
  shiftOut(dataPin, clockPin, 0); // 8 off
  shiftOut(dataPin, clockPin, 255);    // 8 on
  shiftOut(dataPin, clockPin, 0);    // 8 off
  shiftOut(dataPin, clockPin, 0);    // 8 off
  digitalWrite(latchPin, 1); // return the latch pin high

  digitalWrite(latchPin, 0); // ground the latchpin
  shiftOut(dataPin, clockPin, 0); // 8 off
  shiftOut(dataPin, clockPin, 0);    // 8 off
  shiftOut(dataPin, clockPin, 255);    // 8 on
  shiftOut(dataPin, clockPin, 0);    // 8 off
  digitalWrite(latchPin, 1); // return the latch pin high

  digitalWrite(latchPin, 0); // ground the latchpin
  shiftOut(dataPin, clockPin, 0); // 8 off
  shiftOut(dataPin, clockPin, 0);    // 8 off
  shiftOut(dataPin, clockPin, 0);    // 8 off
  shiftOut(dataPin, clockPin, 255);    // 8 on
  digitalWrite(latchPin, 1); // return the latch pin high

You can make this code more efficient using variables and counters, I threw this together to test the concept a couple of years ago.

I had 8 74HC595's wired up to ultra high powered LEDs and this worked fine, I don't think there's a limit to the number of 595's you can piggy-back, so for cost its an economic solution to controlling large numbers of LEDs.

In case there are any "doubting Thomas's" out there, here's the proof of concept = )

Hmm... That makes sense. I see how that could definitely work! I've really got to finally order myself a few parts, and a prototyping board... Any places I should go "shopping"?

I am also considering the use of a few 555 timer ICs to do PWM... I really can't make up my mind though. One thing I know for sure. I wanna try making my own PC board when I can afford the tools. It looks pretty easy, and the design software doesn't kill me.

Thanks for the reply, and the good idea! At the moment I am down to making my own Arduino to fit to the CD drive slot bezel, or using a 555 timer... It seems the best way... I'm trying to understand things!

I really appreciate all the help and advice! I've learned a lot!

There's always a cheaper way of doing things and I'm sure once you've spent a week combing through the forums you'll discover the information that suits your needs.

As for shopping, depending on whats needed its sometimes ok to source components from eBay. Sellers there cannot retaliate with negative feedback anymore so they bend over backwards to preserve their good reputations. You could also check out any of the following, you might pick up a few ideas from the products they sell and most are active in the Arduino community:-

http://www.smileymicros.com/

http://www.wulfden.org/TheShoppe/products.shtml

http://www.nkcelectronics.com/

There's more listed here:-

Hey, those were some great places! I wish a knew that before I took my friend's advice! I ordered most of my parts from DigiKey. There was SO much selection that just finding what I wanted was a learning process. It was crazy.

I decided to build my own mini arduino based on the ATmega168. The whole thing will cost me about 8 dollars to build if you don't count the USB thingy to program it. Eventually I'll be making an arduino with a socket made for just programming the little guys.

I love electronics! I'm addicted!

Thanks for the advice!

I think there is some confusion.

If you want a white light, just buy white LEDs, they are MUCH cheaper.

LEDs don't use voltage. They use current.
LEDs need a minimum voltage in order to switch on. After that, you can destroy them by allowing too big a current to flow. For example if you apply 8.8V without limiting the current, all the LEDs will break. Too little current, and you won't see them.

If you want to have control over the brightness of the three component colours of the RGB LEDs, they need to be wired independently, so the voltages that are relevant are:

Voltage: Red - 2.0v // Green/Blue 3.0-3.4v

not the sum - they are in parallel, not series.

The spec for the RGB LEDs say they switch on at different voltages.
They can all be driven by the same voltage providing it is bigger than the biggest value. For simplicity, lets use 5V to drive them, because that is sufficient, is easy to arrange, and is Arduino friendly.

What this means is each colour component needs a different value of resistor to limit the current to a safe level. It's current that needs controlling, not voltage.

Here's a way to work it out. The spec. says:

Max Continuous Total Forward Current: 25mA

So, lets guess and divide by 3, to get 8mA/colour (near enough, and smaller)

To get 8mA for Red:
5V-2.0V (red forward voltage) / 8mA = resistor = 375 ohm, nearest (larger) common value is 390 ohm

To get 8mA for Green:
5V-3.0V (green forward voltage) / 8mA = resistor = 250 ohm, nearest (larger) common value is 270 ohm

To get 8mA for Blue:
5V-3.4V (blue forward voltage) / 8mA = resistor = 200 ohm, nearest (larger) common value is 220 ohm

I recommend trying these out in a breadboard because the brightness of each colour may be significantly different at the same current, and you may want to tweak them a bit (I'm sure someone has solved this, but I can't find the reference, sorry).

Now, you just need to adjust the colours using PWM, knowing that you are getting close to the maximum brightness from the RGB LED.

The spec. for an Arduino's ATmega says 200mA tops, so that would mean 200mA/25mA (max current/RGB LED) = 8 RGB LEDs at full brightness. Drop the brightness by 25%, and you could drive them directly with the Arduino.

If you want all of the LEDs to be the same colour, then they can be wired in parallel.

You will use 3 ADC pins for your colour-setting potentiometers, so you only have 15 pins left. This could divide nicely into 5 groups of 3 pins for each RGB triple. That is enough to drive 10 RGB LEDs at slightly reduced brightness. You could even have 5 independent colours, with pairs of RGB LEDs showing the same colour.

There are only 6 PWM pins, which means that hardware in the microcontroller controls the ratio of on to off. But, if all you want to do is control some LEDs and read your potentiometers, you could do PWM in software using delayMicroseconds().

Have a look at the example Examples->Analog->AnalogInput and you'll see them using the value of an analogue input to control the time that a LED is on and off. The same technique would allow you to drive all 15 pins (with some ingenuity) as if they are PWM.

If you don't like that approach, you could dig into using interrupts from the PWM timers so that you can switch the other pins to match. So you get the ability to use analogWrite to set the colours, and three small 'interrupt service routines' to make all the pins follow the PWM pins.

To drive more current, and use a simpler arrangement with the 6 hardware PWM pins, use something like a ULN2803, which contains 8 Darlington transistors in one handy package. If you want all the same colour RGB LEDs, I'd spread the load over 6 of the Darlington transistors; put 5 RGB LEDs onto each of 3 Darlingtons. Put 5 of the Reds onto one, 5 of the Blue's onto another, 5 greens onto another, and repeat for the other 5 RGB LEDs. Then drive the 6 Darlington transistors from the 6 PWM pins.

If you follow this approach, you may be tempted to reduce the number of resistors. You might want to have one resistor for the 5 RGB Red LEDs which are in parallel, and similarly for the green and blue. When combining parallel resistors into one, it'll need a much smaller (1/5th) resistance to get enough current for all the LEDs. There are a few issues, but IMHO, the main one is if an LED fails, more current will go through the other LEDs, which may cause one to fail, so more current will flow through the remainder,which may cause another to fail, ... It may be worse. If one part of an RGB LED gets too hot and fails, it may cause the other components in the same LED to get too hot, and fail, which may cause a fault to spread from the red channel to the other colours.

A reasonable alternative is to use resistor arrays:
http://www.rapidonline.com/Electronic-Components/Resistors-Potentiometer/Resistor-Arrays/SIL-Resistor-networks/29581
where a singe component has multiple resistors in one component.

If you want to drive every LED component independently, then you could use shift registers, like 74HC595, because the Arduino hasn't got enough pins to drive each one directly. The code to actually vary the brightness using PWM is much more complex than simply switching them on and off. So try to work that out (or find an example) before trying the technique.

Any technique controlling each LED for part of the time will reduce the brightness. The technique is called time-division multiplexing, which is 'time sharing' a pin between several uses. It is sometimes just called 'multiplexing'. It is popular, but if you have an LED for 1/2 the time, it will be (very roughly) 1/2 as bright, so you might want to experiment with this before building it.

It is not inherent in using shift registers (e.g. 74HC595) that you need to 'multiplex' LEDs and hence reduce the brightness. We can use shift registers to 'make' enough extra pins to control something for all of the time, and reduce the need for 'time-sharing' pins.

You can use a shift register to directly drive a LED and switch it on all the time, look at the code at http://www.arduino.cc/en/Tutorial/ShftOut22.

I think the code in John_Ryan's example is a better fit for situations where you are trying to drive lots of LEDs full on or off, with very few pins. which isn't the problem I think you have posed.

You could drive the LEDs as a "time-division-multiplexed matrix". As you only want 10 RGB LEDs, (30 individual LEDs), and there are 15 Arduino pins available, which is enough to drive 56 LEDs (7 groups x 8 LEDs/group) using time-multiplexing, each LED part of the time. This would give reduced brightness, but individual control of every LED. The software would be a bit more complex, and use the same technique as software PWM.

I'd recommend something like Darlington transistors to sink current from groups of LEDs to keep the brightness high. If you are sneaky, and fiddle directly with the PWM timers, you could use the PWM timers to drive the brightness of every individual LED (but at reduced overall brightness because the LEDs are each on for a fraction of the time).

There are chips which drive LEDs with PWM, e.g. TLC5940, which combine shift registers and PWM. So the cost and hardware complexity may give you the level of control you want. I'd recommend some experiments with the Arduino and some Darlington drivers, and or shift registers first though, because that will help you understand what those chips can do.

Next, look at your PC PSU, and try to find a spare 5V. It is DC.
I'd put a few hundred microfarad of capacitors on your circuit across the 5V PSU wires to reduce electrical noise.

Summary:
a. RGB LEDs use current not voltage, and need independent control of each LED, so don't sum the voltages, it isn't relevant
b. if your PC PSU has a spare 5V, it is DC, and you could use it
c. at slightly reduced brightness, you could drive 10 RGB LEDs directly with an Arduino, but software gets a bit more complex
d. simplify the hardware by using current amplifiers (e.g. Darlington transistors) to allow the 6 PWM pins to drive groups of RGB LEDs

HTH
GB-)

I am very greatful for the wealth of information you have provided me! I cannot thank you enough, sir!

It is 3:00 Am here. Give me the evening to process this, and I'm pretty sure you've set me straight!!! Thank you!!!

I'm pleased if this helped.

Please keep asking questions, but please also use search to see if the answer already exists.

Well, it's now 9am here, so I'm off to bed :slight_smile:

Take care
GB-)

I return! I have assimilated the data, and now that I am more familiar with how electronics work, and since I discovered a few great sources of information... I have ordered all the parts that I need, and the building shall commence! I am still ironing out a schematic, and I'll be posting that soon if anyone is curious.

I'm really excited to try this project... All my parts have come in except the bread board, and the potentiometers... So I have the horses, and no cart. Lol. However, the board shipped today!

By the way... My friend let me practice with his soldering iron today, and I used some of this old solder wire I had... Cardas Quad-eutectic solder is REALLY easy to work with... Just a word of recommendation.

I have yet to purchase my own soldering iron though... There are so many on the market ranging from 10 dollars to 300... I have no idea what to get... Does anyone have any suggestions? I'd like to find a soldering iron that would be idea for a beginner. (One that forgiving.) and then good for detailed work. (Solding PC board components.) Any advice is greatly appreciated! I read a ton of reviews, and my head is spinning...

Soldering irons baffle me...

Thank you all again for the help! I love these forums!

Cardas Quad-eutectic solder

I had a quick look and found Cardas Quad-eutectic solder

It is a mix of tin/lead/silver/ copper.

The European "Restriction of Hazardous Substances Directive" restricts the use of lead, and it is no longer legal to sell electrical goods which use lead solder. AFAIK this is because the view is there is no known lower limit on lead exposure. I am told that lead can be absorbed through the skin.

So please be careful, and avoid contact with it. Always wash your hands after use, and don't eat food while soldering, no matter who yummy those cookies look.

Having said that, lead based solders are much nicer to use than lead-free. It is worth trying lead-free solder as lead-based solder is getting harder to obtain as its use reduces.

As for a soldering iron, IMHO they are quite personal. You could start a flame war arguing about them. I have two, and the cheaper (sub $15) is the one that gets the most use. It has simple 'temperature control', but I leave it almost full on. It works fine.

Lead-free and lead solder have different melting points, so you might want to think about temperature control, or at least ask the supplier if the iron you are considering works with both.

The best advice I was given is buy an iron with a reasonable supply of exchangeable tips, and don't buy one with a fixed tip. If the iron has exchangeable tips, which are easy to get hold of, the iron is probably popular. You will probably find the tip that you like after a bit of experimentation. Several different sizes of tip are handy, one for day-to-day soldering, a second for very fine stuff, and maybe one for bigger, thicker, connections (like soldering motor terminals).

For general bodging around, I like one shaped a bit like a flat screwdriver (but slightly rounder) which is a bit less 2mm. It makes good thermal contact with boards and through hole components. I have a smaller tip for surface mount.

When I was a kid, my uncle gave me an old, second hand, Weller which had a magnetic temperature control mechanism. It was brilliant, but my brother 'inherited' it years ago.

I think I unconsciously adapt my soldering technique a little bit to suit the iron, so the choice of iron wasn't as critical as I had imagined.

What sort of iron has your friend got?
Ask your friend if it's okay to try some lead-fee solder with his iron.
If it is, get hold of some lead free solder, and try it. If you still like it, then it's probably fine.

HTH
GB