Loading...
Pages: [1]   Go Down
Author Topic: Project 04  (Read 3604 times)
0 Members and 1 Guest are viewing this topic.
Helsingborg, Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 1
I am a jammie dodger
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Code:
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 Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the same issues.
Logged

UK
Offline Offline
Jr. Member
**
Karma: 1
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Photography nut trying to make the flux capacitor of macro photography

Leiria-PT
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Life is a game, Can you win?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Edison Member
*
Karma: 45
Posts: 1395
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Newbie
*
Karma: 0
Posts: 4
Life is a game, Can you win?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Code:

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  smiley-confuse

BTW thanks for your help dean_1230 and KirAsh4!
Logged

UK
Offline Offline
Jr. Member
**
Karma: 1
Posts: 62
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Photography nut trying to make the flux capacitor of macro photography

Leiria-PT
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Life is a game, Can you win?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you Nass! x)
Logged

Ohio, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.pdf

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.
Logged

Leiria-PT
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Life is a game, Can you win?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The resistor strengths are all the same, ill check the value as soon as i get home and post here!
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 45
Posts: 1395
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
(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 Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Print
 
Jump to: