Helsingborg, Sweden
Offline
Newbie
Karma: 0
Posts: 1
I am a jammie dodger
|
 |
« on: March 27, 2013, 02:49:04 pm » |
I'm having some problems with the LED. For some reason, it's really hard to make it glow green. I know that the LED is functioning properly, I've made it glow only green, but as soon as I mix colours I get this problem. My r, g and b values are very similar to each other when equally exposed to a light source. They also correspond to being covered up in the same way. My friend has the same problem as me. Is making the LED glow green some inherent problem this type of LED has or have I made some mistake? This is my scaled down code, without the printing and stuff. int r, g, b; void setup() { Serial.begin(9600); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); } void loop() { r = analogRead(A0); g = analogRead(A1); b = analogRead(A2); analogWrite(11, (r/4)); analogWrite(9, (g/4)); analogWrite(10, (b/4)); }
|
|
|
|
« Last Edit: March 27, 2013, 02:59:00 pm by gustavjp »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #1 on: March 28, 2013, 05:00:58 am » |
I have the same issues.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Jr. Member
Karma: 1
Posts: 62
|
 |
« Reply #2 on: April 13, 2013, 10:43:35 am » |
I have the same, I suspect it's either a weak 'green' component in the LED or our eyes are just much more responsive to blue and red, so they drown out the green. In the end I ended up dividing red and blue by 10 and green by 3 to make the different colours visible
|
|
|
|
|
Logged
|
|
|
|
|
Leiria-PT
Offline
Newbie
Karma: 0
Posts: 4
Life is a game, Can you win?
|
 |
« Reply #3 on: April 28, 2013, 06:43:36 am » |
I have the same, I suspect it's either a weak 'green' component in the LED or our eyes are just much more responsive to blue and red, so they drown out the green. In the end I ended up dividing red and blue by 10 and green by 3 to make the different colours visible
Sorry about my noob question but, how do you know for how much you have to "divide" the colors, or you just tryed different values till you get the led glow white?
|
|
|
|
|
Logged
|
|
|
|
|
Ohio, USA
Offline
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #4 on: April 28, 2013, 09:33:56 am » |
I have the same, I suspect it's either a weak 'green' component in the LED or our eyes are just much more responsive to blue and red, so they drown out the green. In the end I ended up dividing red and blue by 10 and green by 3 to make the different colours visible
Sorry about my noob question but, how do you know for how much you have to "divide" the colors, or you just tryed different values till you get the led glow white? Open the serial monitor and look at the values. In my case, the r-g-b values are 131, 105 & 86, which should imply a reddish-green color, but it's more purple (reddish-blue). Getting white is very difficult, as the green element just doesn't transmit well (due either to our lack of sensitivity to green or to a weak green LED element). I manually set the values to see what different ratios gave and the only way I could get a good green led was to set the r-g-b to 3-255-3. Even setting the red and blue to 5 made the light noticeably non-green. To get a white led (ok, mostly white when looking from the side), I manually set the values to 20-255-20. Once the red and blue values hit 50, the color was noticeably blue-purple.
|
|
|
|
|
Logged
|
|
|
|
|
Colorado
Offline
Edison Member
Karma: 45
Posts: 1395
Reviving dead brain cells with Arduinos.
|
 |
« Reply #5 on: April 28, 2013, 10:48:54 pm » |
Not sure what project you're doing, not sure what LED you're using. However, most RGB LEDs have different forward voltage values, so you can't use the same size resistors on all three channels. And if you are using a single resistor on the cathode, you're doing it wrong.
|
|
|
|
|
Logged
|
|
|
|
|
Leiria-PT
Offline
Newbie
Karma: 0
Posts: 4
Life is a game, Can you win?
|
 |
« Reply #6 on: April 29, 2013, 04:43:30 am » |
void loop() { r = analogRead(A0); g = analogRead(A1); b = analogRead(A2); analogWrite(11, (r/4)); analogWrite(9, (g/4)); analogWrite(10, (b/4)); }
I really dont get why we have to divide here by 4  BTW thanks for your help dean_1230 and KirAsh4!
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Jr. Member
Karma: 1
Posts: 62
|
 |
« Reply #7 on: April 29, 2013, 05:03:55 am » |
Tzyn, sorry for not replying sooner but yes I just did it by eye. I measured with a multimeter and there wasn't anything wrong with the circuits so I just figured the LEDs had different brightnesses, so adjusted accordingly. I have the same, I suspect it's either a weak 'green' component in the LED or our eyes are just much more responsive to blue and red, so they drown out the green. In the end I ended up dividing red and blue by 10 and green by 3 to make the different colours visible
Sorry about my noob question but, how do you know for how much you have to "divide" the colors, or you just tryed different values till you get the led glow white?
|
|
|
|
« Last Edit: April 29, 2013, 12:41:40 pm by nass »
|
Logged
|
|
|
|
|
Leiria-PT
Offline
Newbie
Karma: 0
Posts: 4
Life is a game, Can you win?
|
 |
« Reply #8 on: April 29, 2013, 05:20:13 am » |
Thank you Nass! x)
|
|
|
|
|
Logged
|
|
|
|
|
Ohio, USA
Offline
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #9 on: April 29, 2013, 07:31:28 am » |
Not sure what project you're doing, not sure what LED you're using. However, most RGB LEDs have different forward voltage values, so you can't use the same size resistors on all three channels. And if you are using a single resistor on the cathode, you're doing it wrong.
Here's the spec sheet for the RGB LED: http://arduino.cc/documents/datasheets/LEDRGB-L-154A4SURK.pdfForward voltages are 1.95/3.3/3.3 respectively. As for the number and size of the resistors, going from memory (don't have the book in front of me at the moment) I think the resistor strengths are all the same. Maybe someone that has the book handy can check.
|
|
|
|
|
Logged
|
|
|
|
|
Leiria-PT
Offline
Newbie
Karma: 0
Posts: 4
Life is a game, Can you win?
|
 |
« Reply #10 on: April 29, 2013, 11:28:44 am » |
The resistor strengths are all the same, ill check the value as soon as i get home and post here!
|
|
|
|
|
Logged
|
|
|
|
|
Colorado
Offline
Edison Member
Karma: 45
Posts: 1395
Reviving dead brain cells with Arduinos.
|
 |
« Reply #11 on: April 29, 2013, 08:44:55 pm » |
Forward voltages are 1.95/3.3/3.3 respectively.
As for the number and size of the resistors, going from memory (don't have the book in front of me at the moment) I think the resistor strengths are all the same. Maybe someone that has the book handy can check.
So therein lies (part of) the issue. With different voltages, you really need different resistor sizes as well. Assume you're supplying 5V to them, and assuming you want to drive the LEDs at 20mA, you should be using: (5V - 1.95)/20mA = 152.5 Ohm, round it up to the nearest size and you get 180 Ohm, which when recalculated means the LED is being driven at 16.9mA (5V - 3.3)/20mA = 85mA, round it up to the nearest size and you get 100 Ohm, recalculated gets you 17mA on the LED You can use exact sizes, if you can find them, however going to the nearest common size is usually cheaper and the human eye will have a hard time noticing the difference anyway.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #12 on: June 09, 2013, 05:21:32 pm » |
Hello, i cant get my LED to change color at all, i've already checked my circuit/code twice and cant find any error. when i wave my hand over the photoresistors i get different values in the serial monitor but the led never changes color... any help?
thanks
|
|
|
|
|
Logged
|
|
|
|
|
|