Rookie looking for guidance with 4 Full Color LEDs

Greetings,

Firstly, I'm a absolute rookie .. as noted in the subject title, so excuse the rudimentary questions. It's really exciting to step outside the realm of software engineering to hardware.

I'm working toward my first Arduino project, the basic concept involves;

  • Arduino Uno
  • 4 RGB LEDs (6 legs)
  • 1 DC Motor
  • and a alcohol gas sensor

The user blows into the alcohol sensor > input > arduino calculates input and returns output as color, derived from a color scale*> output > RGB LEDs tween to color output value. The DC Motor is not apart of this interaction, it run's in the background.

To tackle this project i've decided to take a stepwise approach, separate it into 3 projects then bring it together at the end...

The first project is to illuminate the 4 RGB LEDs to a specific color in unison with a potentiometer, the potentiometer will stand in for the sensor before moving onto the next phase. The LEDs i have are 6 legged, rather than 4, which brings me to my first question... i'm unsure how this will impact in respect to programming? (e.g making it more complicated - 4 legs good, 6 legs bad?) i've found it hard to get info on this...

From what i understand, i need to use shift registers to run this many LEDs from the Arduino Uno as it has not got enough pins...

I've designed a breadboard diagram from this tut; http://www.arduino.cc/en/Tutorial/ShiftOut

The LEDs are 5mm, i need them to be as bright as i can get them.. would this involve an external power source?

This may be stupid question, but its in context to the LEDs question... i have 12v adapter is it safe to plug it into the power input on the arduino as an external power source? or does it need an independent power supply, like so.. http://www.tinkersoup.de/product_info.php?products_id=162

before i start programming i'd like to get the communities advice on whether or not this is the best/easiest approach to the hardware...

if i've neglected to provide any detail's, pls ask

thanks, cam

  • green = sober, yellow = tiddley, red = gone.

4 RGB LEDs (6 legs)

RGB LEDs have 4 legs (R, G, B, common). Where did you get 6?

To tackle this project i've decided to take a stepwise approach, separate it into 3 projects then bring it together at the end

Excellent idea.

The LEDs i have are 6 legged

Guess I should have read ahead. Do you have a link for these odd creatures? Are they just three separate LEDs in one case?

From what i understand, i need to use shift registers to run this many LEDs from the Arduino Uno as it has not got enough pins...

From the description you have provided, I'm not sure why you need more than 1 RGB LED or three separate LEDs. Red = sleep it off. Yellow = call a cab. Green = drive yourself home.

That schematic has some issues, I think. Two of the LED legs are connected to ground. You are then powering 4 of them. That doesn't seem right to me. I would expect only to power three of them (R, G, and B).

Shift registers are generally cascaded, not driven in parallel as you have shown.

i have 12v adapter is it safe to plug it into the power input on the arduino as an external power source?

If it is wired correctly (i.e matches the power in connector of the Arduino), yes. The difference between your 12v (wall-wart?) power supply and the linked one is that the linked one is a regulated power supply, and yours is likely not. The power in connector goes to the on-board regulator, though, so as long as the unregulated voltage is within limits, it will work.

Hi PaulS,

thanks for the prompt reply,

i'm currently living in berlin, the local electronics franchise is 'Conrad' this is where i sourced the LEDs, i believe this is them;

http://www1.conrad-uk.com/scripts/wgate/zcop_uk/~flN0YXRlPTEyMjY3NDkxNjI=?~template=PCAT_AREA_S_BROWSE&glb_user_js=Y&shop=UK&p_searchstring=rgb+led&s_haupt_kategorie=&zhmmh_area_kz=&p_init_ipc=X&p_page_to_display=DirektSearch&~cookies=1&scrwidth=1440

From the description you have provided, I'm not sure why you need more than 1 RGB LED or three separate LEDs

sorry i should of mentioned, this is for an exhibition, the number of the LED's corrospond with the structure they are housed in. the 4 LEDs illuminate 4 faces of a cube. the color scale with probably harness a wide range of colors, and ideally i'd love to tween between them. like so, http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1288285333

thanks for the info on the power adapter aswell!

...also

That schematic has some issues, I think. Two of the LED legs are connected to ground. You are then powering 4 of them. That doesn't seem right to me. I would expect only to power three of them (R, G, and B).

here's the schematic that influence the way i wired the 6 legged LEDs, i've tryed it and got to work but its only using one, i'll have to buy the shift registers on monday and have a play.

opps ... http://fritzing.org/projects/rgb-led-mixer/

sorry i should of mentioned, this is for an exhibition, the number of the LED's corrospond with the structure they are housed in. the 4 LEDs illuminate 4 faces of a cube. the color scale with probably harness a wide range of colors, and ideally i'd love to tween between them.

You only have one sensor (the potentiometer that will be replaced by the alcohol sensor). How will you choose different colors for the 4 LEDs based on only one sensor?

hmm good question, not sure.. is it possible to achieve with 1 input or does it require 3?

my assumption is; if the potentiometer input reading is from 0 - 1028, could each color RGB be mapped individually to shift through color values set in a colorRangeArray['color','color','etc'] ?

Each RGB could display a different color. What I was getting at was whether that was a requirement. If all the LEDs are to display the same color, you don't need shift registers. You simply need 3 PWM pins.

If all 4 are to display different colors, then you will need the shift registers, and some way to map the potentiometer value to the color each is to display.

Before you start trying to work out that mapping, you need to make sure that the alcohol sensor output will be in the same range. It will not have a larger range, but the actual range of values achievable (by humans breathing on it) may be considerably less.

Ok, this is really good to know!

The 4 RGB LEDs will display the same color at the same time, so i’ll begin to rework my schematic now using 3 PWM pins & my 4 RGB LEDS (4 legged)*…

… will this require the 4 RGB LEDS to be daisy chained? to share the PWM output infomation?

I’ve done some research into sensor output the Analog Pin, this link (3rd paragraph) mentions 0 - 1028 input, which would be perfect;
http://nootropicdesign.com/projectlab/2010/09/17/arduino-breathalyzer/

the reading doesn’t need to be that accurate.

thanks again PaulS, really appreciate your help.

  • i’m going to go purchase 4 legged RGB LEDs tomorrow, to make things easier

The 4 RGB LEDs will need to be connected together. That is, all R legs, all G legs, all B legs, and all ground legs get connected together. The problem, now, is that the total current from one pin is limited, and is now shared by 4 LEDs. This may require the use of a transistor that is turned on by the PWM pin, that then turns on an external voltage source to power the LEDs. And, now we are stepping outside of my comfort zone. Knowing what needs to be done, and knowing how to do it are two different things.

Instead of measuring the resistance directly, we measure the voltage level at the point between the sensor and a load resistor. The sensor and load resistor form a voltage divider, and the lower the sensor resistance, the higher the voltage reading will be. An Arduino analog input pin is a good way to measure the voltage and gives us a reading between 0 and 1023. Higher values mean more alcohol.

The fixed resistor and variable resistor (the alcohol sensor) means that there is a limit on the voltage that is measurable across the voltage divider, and means that you will not get values that range from 0 to 1023.

What you will need to do is to experimentally determine the range of values that you do get, and use the map function to map the actual range to 0 -> 255, to provide a PWM value for the RGB LED. A smooth transition across the whole color spectrum from black to white is easy to define. A smooth transition from green to yellow to red will be harder. Happy experimenting, though.

He will ulitmately need something like one of these.
I have used the top configuration with no problem.
Never tried the bottom - which is selected will depend on the RGB LEDs ued.

Hey Crossroad,

thanks alot for the schematic!
i’ll order the extra 4 leggd RGB LEDs and transistors tomorrow i need & will have a play, then update the thread with my results…

as mentioned earlier, i need the LEDs to be as bright as possible, the spec’s on the website describe the top voltage as 3.2v, will this effect what transistor’s i need to purchase tomorrow?

I’ve currently got a 547 transistor, and was thinking of getting 2 more.

btw, i got the 6 legged RGB LED working, cycling through random colours, turns out its RGBB. The two extra legs connect to gnd, rather than the 5v power output.

not sure why theirs an extra blue LED, it doesn’t seem brighter than the 4 legged model…

Can you post a link to the LED you're planning on? A 547 NPN transistor like this one? http://www.electrokits.com/downloads/pdf/BC547-Datasheet-Fairchild.pdf

Most LEDs have a current limit of 20mA, 80 mA for 4 in parallel thru a transistor I wouldn't expect to be an issue. You'll just need to adjust the resistors some. You have access to a multimeter that can measure mA? If the diode actually drops 3.2V, that leaves 1.8V for the transistor & resistor. Lets say the transistor drops 0.7V, that leaves 1.1V across the resistor. V=IR -> V/I = R -> 1.1V/0.02mA = 55 ohm, 56 is a standard value. If the diode drops less, that will increase the voltage across the resistor and the current allowed. You'll have to do some measuring & see what the LEDs & transistor are really dropping & pick your resistors accordingly. A rise of just 0.5V will get you up to 28mA and could blow your LEDs.

You will need to pick a resistor for the base also that will limit the current out of the arduino pin. With a voltage of ~0.7V at the base turning on the transistor (with emitter grounded) you will have 4.3V across the base resistor - so you'll want like a 220ohm or higher base resistor to keep current out to about 20mA.

I'm going to use the 4 legged version; http://www.sparkfun.com/products/105

But here's the RGBB LEDs i currently have; http://shop.conrad-uk.com/components/optoelectronics/led/special-leds/rgb-leds-general/185388.html

Yip, my transistor is identical and yep i've got a multimeter on loan from a friend. I'll keep an eye on the mA.

Thanks for the details CrossRoads, will report back soon!

Okay, that RGD LED and that transistor are not gonna work together. You need PNP transistors to source current into the anodes.

This is a Common Cathode LED, meaning the common pin goes Low while the individual pins must be High to turn them on. They have different voltage drops, you will have to account for that with your resistor selection. They have different brightnesses too - the green is way brighter than the blue & red. Maybe the human eye doesn't see it that way. The chart on page 3 says the Green will have degraded nearly 10% in 360 hours of use at 20mA. Is there some reason you selected a tricolor LED vs 3 discrete one? The tricolor is usually more expensive, and you can get VERY bright LEDs from places like this: http://www.superbrightleds.com/cgi-bin/store/index.cgi?action=DispPage&Page2Disp=%2Fleds.htm and have more options for wiring them up.

Parts arrive tomorrow ;D

I've put together a precursory schematic from CrossRoads circuit, I've only just began reading circuits diagrams, so i find the Fritzing schematic's are a good/very visual way of getting into the hardware.

If theirs any glaring mistakes you can spot, pls tell me.

Thanks! cam

Being just a picture, the schematic doesn't tell the whole story, maybe. You will find that the same value resistor on all three legs of the LED does not give the same illumination or intensity for each color. The specific characteristics of each LED in the housing (and they are not all the same) need to be taken into account when sizing the resistors. Even after choosing the "right" resistor, you may need to change it to provide "equal" intensity for all colors. Or not. Depends on your needs.