Pages: [1]   Go Down
 Author Topic: Mapping (R,G,B) values to wavelengths (nm) for an RGB LED strip  (Read 3534 times) 0 Members and 1 Guest are viewing this topic.
Offline
Newbie
Karma: 0
Posts: 7
 « on: January 12, 2012, 06:32:55 pm » Bigger Smaller Reset

Hi,
I am wanting to be able to control the levels of red, green and blue light intensities on an RGB LED strip - in relation to the corresponding light wavelengths (in nanometres). There is actually no unique one-to-one mapping between wavelength and RGB values, however it can be approximated as shown on this site http://www.efg2.com/Lab/ScienceAndEngineering/Spectra.htm.

I need help with how to script this. So far, all I can think of is defining the RGB levels of wavelengths at increments where x nm = (R,G,B) (eg. every 10 nm between 380nm and 780nm- so 380 nm = (100,0,100); 390 nm = (125, 0, 150) etc) and somehow scripting that in so that when you turn a potentiometer, the wavelength goes up or down. This would mean the combination of intensities of R,G,B would change accordingly, which would be relayed to the LED.

HARDWARE:
The RGB LED strip I am using is analog and common anode http://elektronik-lavpris.dk/product_info.php?products_id=111078

I think I will be connecting the arduino uno, LED strip and +v this way, allowing each colour of LED to be controlled individually: http://www.ladyada.net/wiki/_media/products/rgbledstrip/ledstripbjt.gif

I imagine the physical controller to be a potentiometer dial or slider of some sort, to make a smooth transition along the scale of wavelengths between 380 and 780nm. (other suggestions welcome!)

AIM:
The reason I want to be able to do this project is to design and create a light which can simultaneously act as a therapy light for seasonal affective disorder (SAD, or Winter blues) and as a plant grow light. Each of these respective functions has a different optimal light wavelength, which I would like to be able to slide between depending on the use.

Any help or suggestions would be wonderful thankyou! I am kind of new to all this!

Zana

http://www.efg2.com/Lab/ScienceAndEngineering/Spectra.htm
 Logged

Massachusetts, USA
Offline
Tesla Member
Karma: 201
Posts: 8684
 « Reply #1 on: January 12, 2012, 06:51:34 pm » Bigger Smaller Reset

That chart references http://www.physics.sfasu.edu/astro/color/ which has a link to http://www.physics.sfasu.edu/astro/color/spectra.html which contains a Fortran program for calculating the curves.  That should be enough to allow you to generate a set of RGB values for wavelengths from 380 to 780.

Code:
WL = 380. + REAL(I * 400. / M)

IF ((WL.GE.380.).AND.(WL.LE.440.)) THEN
R = -1.*(WL-440.)/(440.-380.)
G = 0.
B = 1.
ENDIF
IF ((WL.GE.440.).AND.(WL.LE.490.)) THEN
R = 0.
G = (WL-440.)/(490.-440.)
B = 1.
ENDIF
IF ((WL.GE.490.).AND.(WL.LE.510.)) THEN
R = 0.
G = 1.
B = -1.*(WL-510.)/(510.-490.)
ENDIF
IF ((WL.GE.510.).AND.(WL.LE.580.)) THEN
R = (WL-510.)/(580.-510.)
G = 1.
B = 0.
ENDIF
IF ((WL.GE.580.).AND.(WL.LE.645.)) THEN
R = 1.
G = -1.*(WL-645.)/(645.-580.)
B = 0.
ENDIF
IF ((WL.GE.645.).AND.(WL.LE.780.)) THEN
R = 1.
G = 0.
B = 0.
ENDIF

Change .GE. to >= and .LE. to <= for a start.
 Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline
Edison Member
Karma: 43
Posts: 1553
 « Reply #2 on: January 12, 2012, 06:53:54 pm » Bigger Smaller Reset

The uses you've described only seem to require a single spectrum - that of sunlight. Plants obviously use sunlight and as I understand it, the light box used in SAD is designed to produce a spectrum similar to or the same as sunlight. So all you need to know is the colour temperature of sunlight and then map that to RGB. Even if plants need a different spectrum than a lightbox, you don't need a potentiometer and calculations for all the in-between colours. You just need a switch between the two types in which case the Arduino is superfluous.
However, the light boxes produce a very bright light and a few LED strips aren't going to equal one of these light boxes. You might find bright white LEDs to be more useful if they produce the correct spectrum.

Pete
 Logged

Where are the Nick Gammons of yesteryear?

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #3 on: January 12, 2012, 07:10:34 pm » Bigger Smaller Reset

Thankyou johnwasser! That will certainly get me started.

Also- very good points el_supremo. I need to do some thinking... I guess the reason I wanted to be using arduino is because I want the LED strip to be activated into 2 modes:
1. by a photocell sensing when the module is in shadow/ darkness - to stimulate plant growth (wavelength adjustable using the potentiometer)
2. by a motion sensor when somebody approaches it to use it for SAD treatment (wavelength set)

From my research on the internet it seems you can use light more efficiently for both purposes if you use the optimal wavelength (ie. 1000 lux at 464nm for SAD instead of 10,000 lux of white light). Also 440nm for vegetative growth in plants, and 680nm for flowering.

Cheers
Zana
 Logged

Massachusetts, USA
Offline
Tesla Member
Karma: 201
Posts: 8684
 « Reply #4 on: January 12, 2012, 07:30:54 pm » Bigger Smaller Reset

One problem you will have is changing the balance of various wavelengths will only SIMULATE a particular monochromatic color, it won't have the spectrum of that color.  To get a 464nm light you can't just mix some 400nm and some 500nm lights in the right ratio.  The eye will see the desired color but whatever electrochemical processes that 464nm light triggers to be effective agains SAD would probably not be fooled.

Perhaps you should look for LED's that have the wavelength you need.
 Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #5 on: January 12, 2012, 07:50:59 pm » Bigger Smaller Reset

Hmmm, the constantly evolving design process continues then! Perhaps I need two lights within the one unit- an LED at the correct wavelength for SAD triggered by the motion sensor, and an adjustable RGB LED for the plants triggered by the photocell... Or as el_supremo suggested, one very bright light strip with a colour temperature the same as natural daylight, simply activated by the photocell.
I will do some thinking and be back.