Notifications
Clear all

LED color vs. LED brightness?  

  RSS

GlennStasse
(@glennstasse)
New Member
Joined: 3 months ago
Posts: 3
2020-06-25 10:06 pm  

I’m a true newbie. Sorry if this question has an obvious answer to most of you. But...

I'm playing around with my Arduino and a 3-color LED. The simple sketch has you varying the BRIGHTNESS of each color between 0 and 255. So that’s basically 8-bit color, right? Except, wait! Does changing those values actually change the “color” (frequency) of the emitted light? Or, does it change the INTENSITY of that light but not the color? I got to thinking about this because I thought it would be an interesting exercise to automate showing all the possible colors (16 million is it?). But I don’t see anything like that. In fact, it looks like there are only 8 variants of colors (3 binary places).

 

am I off the beam here?


JoeLyddon liked
Quote
Topic Tags
starnovice
(@starnovice)
Estimable Member
Joined: 1 year ago
Posts: 165
2020-06-25 10:15 pm  

There are 3 leds inside of a multicolored led, red, green, and blue.  What you are varying is the intensity of each led and then it is your eye that makes the color interpretation.

Pat Wicker (Portland, OR, USA)


ReplyQuote
robotBuilder
(@robotbuilder)
Reputable Member
Joined: 1 year ago
Posts: 467
2020-06-25 11:54 pm  

Actually it is the brain that makes the colour interpretation. The brain uses data provided by the sensory data from three different types of retina cells in the eye. Colour is just how we experience the output of this computation. Colour only exists as a brain code, it does not exist "out there" in the physical world.

https://archive.nerdist.com/5-optical-illusions-that-show-you-why-your-brain-messes-with-the-dress/

In order for a AI to see the world as we do it would have to perform the same computations. As it stands now computers just code colour as a vector of three values. 

This post was modified 2 weeks ago 2 times by robotBuilder

ReplyQuote
JoeLyddon
(@joelyddon)
Reputable Member
Joined: 10 months ago
Posts: 273
2020-06-26 2:02 am  
Posted by: @glennstasse

I’m a true newbie. Sorry if this question has an obvious answer to most of you. But...

I'm playing around with my Arduino and a 3-color LED. The simple sketch has you varying the BRIGHTNESS of each color between 0 and 255. So that’s basically 8-bit color, right? Except, wait! Does changing those values actually change the “color” (frequency) of the emitted light? Or, does it change the INTENSITY of that light but not the color? I got to thinking about this because I thought it would be an interesting exercise to automate showing all the possible colors (16 million is it?). But I don’t see anything like that. In fact, it looks like there are only 8 variants of colors (3 binary places).

 

am I off the beam here?

Sounds interesting...  Have you tried modifying your sketch by adding a simple: 

For i=0 to 255

Output i to LED & delay a little

Next

That would only display 255 colors, etc.   How would you do it for more colors?  Sounds interesting...  Maybe that's what you have already done?

 

Have Fun,
Joe Lyddon

www.woodworkstuff.net


ReplyQuote
damaru
(@damaru)
Active Member
Joined: 6 months ago
Posts: 13
2020-06-26 7:36 pm  

You hook each colour's pin up to a different output and cycle through colours like this (I haven't tested it, I just wrote it off the top of my head):

const int redPin = 3;

const int greenPin = 5;

const int bluePin = 6;

int redVal = 0;

int greenVal = 0;

int blueVal = 0;

int redStep = 1;

int greenStep = 3;

int blueStep = 5;

// set pinmode to OUTPUT in the setup() function

pinMode(redPin, OUTPUT); // etc

void loop() {

// output the 3 values to the 3 pins

analogWrite(redPin, redVal); // etc

// update the values

redPin += redStep;

if (redStep > 255) {

   redStep -= 256;

} // same for the other colours.



delay(100);

ReplyQuote
GlennStasse
(@glennstasse)
New Member
Joined: 3 months ago
Posts: 3
2020-06-26 9:15 pm  

Well, thanks all for your thoughts. In fact, I have tried a sketch that randomly selects a different value for each color, mostly because I couldn’t think of a way to vary all 3 values uniformly. My original thought was to try every possible value and combination thereof just to see what all the colors looked like. I wound up settling for 3 random selections for each loop. That was enough to set me off on this quest. Once I decided intensity, what is apparently varied by setting this value, is not the same as hue, shades of color, I just decided with 3 variables I can make only 8 colors and I wrote a sketch to do that. It’s not very satisfactory looking!

As for the neurological interpretation of color and all that, I’m going to argue a little here. First, I will agree that a typical computer screen with lots of pixels of varying “color” is interpreted by your eye, blended and smoothed, and so forth. But that’s MANY pixels grouped together by your eye. This is ONE LED! (OK, three actually) In essence, one pixel. In my little experiment above you can see each of the colors separately when all 3 were activated. I’m guessing you need some number of LEDs in a group for it to look like some mixed color like lavender or orange.

So I still have this question: What are you actually varying when you change these values? Aren’t you adding more current (or is it voltage?) as you raise the value from 0 to 255? I’m guessing the LED, because of its physical construction, can only give off one frequency of light, or “color” for each internal LED. If so you only get 8 colors, not 16M.

i don’t mean to be argumentative here. Really. And thank you all for your responses!

 

glenn


ReplyQuote
robotBuilder
(@robotbuilder)
Reputable Member
Joined: 1 year ago
Posts: 467
2020-06-26 11:13 pm  

The analog output of the Arduino is turned on (5 volt)) and off (0 volt) at a high frequency called pulse width modulation. The longer the pulse in on the brighter the LED. If you wanted a continuous analog signal you would have to use a digital to analog converter (DAC). You can combine the output from three LEDS each giving off a different wavelength of light such as a red LED, a green LED and a blue LED to make a range of colors.

Each pixel is a different combination of two different LEDS which have been varied between 0 and 255.

mixingColors

 

 

This post was modified 2 weeks ago 4 times by robotBuilder

ReplyQuote
GlennStasse
(@glennstasse)
New Member
Joined: 3 months ago
Posts: 3
2020-06-27 6:54 pm  

@robotbuilder.   Thanks...that helps me a lot. I’m going to play some more and get my understanding fixed.


ReplyQuote
JoeLyddon
(@joelyddon)
Reputable Member
Joined: 10 months ago
Posts: 273
2020-07-02 7:12 pm  

This might let you have a little extra Fun with LEDs...

 

 

Have Fun,
Joe Lyddon

www.woodworkstuff.net


ReplyQuote