Need some advice on getting a RGB LED to work with Raspberry

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
waltfeld
 
Posts: 3
Joined: Fri Oct 11, 2013 1:25 am

Need some advice on getting a RGB LED to work with Raspberry

Post by waltfeld »

Hello,

For a college project, I'm attempting to get the TCS34725 color sensor and a Diffused RGB (tri-color) LED - Common Anode to work together in order to detect different colors.

However when attempting to figure out the wiring for this, I realized that red requires 2.2 volts while blue and green require around 3.8 volts or so.

So my question is: is there alternate LED's that I could maybe purchased, so is there a work around that I could do?

Another question: Does the TCS34725 color sensor have a built in LED? should I be using that instead?

As far as I can tell, if I use GPIO pins to turn switch between the different colors of the LED, it will only provide 3.3 volts, not nearly enough voltage. I could just run it a straight 3.3 volts and see how bright the LED is, but I'm not sure if that is safe to do.

I was planning on writing a python script to get the color sensor to basically turn on when the PI receives a signal from one it's GPIO pins that the item is in place. (The button is depressed because of the weight of the object). The script will then use the LED to determine what color it is.

I attempted to follow the tutorial for the Audrino for assembly and wiring since according to my research on google - I have found, it should be relatively the same.

Any help or advice in this matter would be appreciated. I don't really expect much help other than a general nudge in the right direction.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need some advice on getting a RGB LED to work with Raspb

Post by adafruit_support_mike »

The color of an LED depends fundamentally on its forward voltage. The wavelength of the light depends on the energy in the photons, and the energy in the photons depends on how much of a voltage drop the electrons experience as they pass through the LED.

What you want to do is find resistors that take up the voltage difference between the LED's forward voltage and your supply voltage at the current level you want to send through the LED (usually about 20mA). Red LEDs usually have a forward voltage of 1.2v to 1.5v at 20mA, so you'd want a 100 ohm resistor between the LED and the VCC rail. Green LEDs usually have a forward voltage between 1.7v and 2v at 20mA. You'd want an 82 ohm resistor for that.

Blue and white LEDs are tricky when running from 3.3v. Some will work, others won't. It's usually easiest to use at least a 3.7v supply when working with either of those colors.

The TCS34725 does have an onboard white LED that will work from a 3.3v supply. You can find instructions on working with it here: http://learn.adafruit.com/adafruit-colo ... s/overview

User avatar
waltfeld
 
Posts: 3
Joined: Fri Oct 11, 2013 1:25 am

Re: Need some advice on getting a RGB LED to work with Raspb

Post by waltfeld »

adafruit_support_mike wrote:The color of an LED depends fundamentally on its forward voltage. The wavelength of the light depends on the energy in the photons, and the energy in the photons depends on how much of a voltage drop the electrons experience as they pass through the LED.

What you want to do is find resistors that take up the voltage difference between the LED's forward voltage and your supply voltage at the current level you want to send through the LED (usually about 20mA). Red LEDs usually have a forward voltage of 1.2v to 1.5v at 20mA, so you'd want a 100 ohm resistor between the LED and the VCC rail. Green LEDs usually have a forward voltage between 1.7v and 2v at 20mA. You'd want an 82 ohm resistor for that.

Blue and white LEDs are tricky when running from 3.3v. Some will work, others won't. It's usually easiest to use at least a 3.7v supply when working with either of those colors.

The TCS34725 does have an on-board white LED that will work from a 3.3v supply. You can find instructions on working with it here: http://learn.adafruit.com/adafruit-colo ... s/overview
Thank you for the fast response. =)

After reviewing your post yesterday and making a decision, I ordered a pack of 50 RGB 5mm Round Head Common Cathode RGB Light LED Emitting Diodes as seen in the link provided from Amazon.

The LED according to the reviews will work on the Raspberry Pi since it's meant for a voltage supply of 3.3v. Don't worry, I'm not asking for a refund on the $2 RGB LED I purchase from you fine folks, I'll use it in another non-school oriented project I have in mind. Your response confirmed what I thought, but I needed to double check my work as I much rather not burn out the LED on accident if I can help it.

I have another few questions regarding the on-board white LED on the sensor. It's more of double checking however I want to be sure I'm right.

Would the on-board white LED alone be able to detect what type of color the block is? I know the tutorial you provide for the Audrino requires a RGB LED but I wasn't sure what the point of having an on-board white LED would be if it's primarily purpose is to detect color by emitting only a certain color and gauging how much reflection comes back.I am under the assumption you have to cycle through the RGB LED in order to get a value for each RGB and then you just compare whichever one is highest to determine what color it is. Perhaps there is another use for it that I'm not seeing or don't know about.

Basic description of my college project is the following that may help:

In our automated cell, we were planning on building it so that a single .9" wooden blocks that is either red, green or blue color get pushed into the "loading bay" from a block dispenser/storage area. From there, the block would be moved by a claw into certain area based on the color of the blocks. Which then eventually make it's way back to block dispenser/storage area.

The "loading bay" is where we determine what color it is. We were planning on either painting it completely white or taping white paper to make sure the color sensor wouldn't get any false readings.

Do you know what range off the top of your head would be for it to get accurate reading of a color block that's .9 inches on a side? Like does it have to within a foot, inches or centimeters?

I have done the initially soldering to connect the 7 header pins to the color sensor but I haven't hooked it up yet to the raspberry pi yet as I want to make sure I do it right. I can't really afford to buy much more new parts if something goes afoul/gets zapped.

As for the resistors, it seems like according to this LED calculator, that I would need resistors that are 1/8 wattage with a 3.3v power supply. On the questions on the product page for the new RGB Led's that I purchased , it was said that the LED on 3.3 volts typically operates at the following:
  • Red: 1.8 volts +/- 10% @ 11mA = 180 ohms
  • Green: 2.0 volts +/- 10% @ 11mA = 120 ohms
  • Blue: 2.0 volts +/- 10% @ 11ma = 120 ohms
However in a recent review a customer stated when he bought it in February 4th that it operates at:
  • Red: 1.6 volts +/- 10%
  • Green: 2.2 volts +/- 10%
  • Blue: 2.4 volts +/- 10%
There wasn't a listing for what mA he was using them at however. Would you happen to know where I can determine what mA the raspberry pi GPIO pins typically output so I can get the proper resistors? Yes I do realize this isn't exactly your product especially when I got it from Amazon so it's a bit of a oddball question. I would have ordered it from you guys if you offered a RGB 3.3v Led. There's about 50 of them in that bag so I don't care if the answer is wrong/inaccurate and I fry a bunch, nor would I hold Adafruit liable for any losses. I'm viewing this as a learning process which is what my professor really wants.

Thanks for any help in this matter and being patient with me, I really appreciate the great customer service.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Need some advice on getting a RGB LED to work with Raspb

Post by adafruit_support_mike »

waltfeld wrote:Would the on-board white LED alone be able to detect what type of color the block is?
Yes.

The TCS34725 has a built-in array of sensors with red, green, blue, and clear filters. Its output will have red, green, blue, and overall brightness components no matter what kind of light source you use. The white LED on the breakout has a known color spectrum, so you can estimate colors from a known reference, rather than having to take a white-balance reading to characterize your light source.

You can take color measurements with a single unfiltered sensor if you take readings when the object is lit by red, green, and blue light. That's where you'd use an RGB LED. It works if you can block out all other sources of light while you take each reading, but there's no way to characterize a light source with a white-balance reading.

The TCS34725 doesn't need that though.
waltfeld wrote:Would you happen to know where I can determine what mA the raspberry pi GPIO pins typically output so I can get the proper resistors?
The RasPi's GPIO pins have some important limits in terms of current. No pin can safely deliver more than 16mA. All 17 GPIO pins draw power from the same part of the microprocessor, and that supply can only deliver a total of 51mA.

You can only run three pins at the 16mA limit at any time. Adding a fourth would take the total current to 64mA, which could damage the microprocessor.

Basically, the pins are there to transmit information, not to supply power.

User avatar
waltfeld
 
Posts: 3
Joined: Fri Oct 11, 2013 1:25 am

Re: Need some advice on getting a RGB LED to work with Raspb

Post by waltfeld »

adafruit_support_mike wrote:
waltfeld wrote:Would the on-board white LED alone be able to detect what type of color the block is?
Yes.

The TCS34725 has a built-in array of sensors with red, green, blue, and clear filters. Its output will have red, green, blue, and overall brightness components no matter what kind of light source you use. The white LED on the breakout has a known color spectrum, so you can estimate colors from a known reference, rather than having to take a white-balance reading to characterize your light source.

You can take color measurements with a single unfiltered sensor if you take readings when the object is lit by red, green, and blue light. That's where you'd use an RGB LED. It works if you can block out all other sources of light while you take each reading, but there's no way to characterize a light source with a white-balance reading.

The TCS34725 doesn't need that though.
waltfeld wrote:Would you happen to know where I can determine what mA the raspberry pi GPIO pins typically output so I can get the proper resistors?
The RasPi's GPIO pins have some important limits in terms of current. No pin can safely deliver more than 16mA. All 17 GPIO pins draw power from the same part of the microprocessor, and that supply can only deliver a total of 51mA.

You can only run three pins at the 16mA limit at any time. Adding a fourth would take the total current to 64mA, which could damage the microprocessor.

Basically, the pins are there to transmit information, not to supply power.
Hmmm alright, thanks very much for the help. :)

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”