Pages: [1]   Go Down
Author Topic: BlinkM Color from analog inputs.  (Read 27024 times)
0 Members and 1 Guest are viewing this topic.
Australia
Offline Offline
Full Member
***
Karma: 8
Posts: 161
You dont have to touch powerlines for them to kill you, even looking at them for too long will make them angry.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have an interesting issue here, I have a touchscreen, from which I can get two values, one X position, one Y position. I wish to use these two values to manipulate a BlinkM I2C RGB LED to make it produce some colours. The colours are (int rgb hex color values):

Red (0xFF,0x00,0x00)
Purple (0x66,0x33,0xFF)
Yellow (0xFF,0xFF,0x00)
Blue (0x00,0x00,0xFF)
White (0xFF,0xFF,0xFF)

I wish to have each of the first colors acutated to their full values at the four corners of the pad, and as you move your finger between corners, I wish to morph the colors  in the space between the corners, possibly using white as the vale of having your finger at the dead center of the screen.

I believe I will need to design an algorithim or three to use the two input values and to produce each channel of color, which I will send to the I2C bus. I am perfectly comfortable using the I2C setup, I just need to work out how to get to work on the algorithim. Can anyone point me in the right direction?
« Last Edit: January 22, 2011, 01:20:39 am by fliggygeek » Logged

"Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent di

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50097
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You want to vary 3 values (r, g, and b) based in 2 input (x and y)? That's going to be tricky.

I'd start with trying to vary the intensity of two of the colors (r and g) as the values (x and y) increase/decrease. When you get that working (the algorithm is easy; the implementation may or may not be), you could work out how to value the third color - perhaps as the inverse of the square root of the sum of the squares of the two values.

This means that the colors in the corners won't be the colors you defined. But, there isn't a linear means of morphing through the colors of the rainbow with those colors in the corners.
Logged

Australia
Offline Offline
Full Member
***
Karma: 8
Posts: 161
You dont have to touch powerlines for them to kill you, even looking at them for too long will make them angry.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if I use a simple setup of this(intermediate values removed)
PWY
WWW
RWB

P = Purple
W = White
R = Red
B = Blue
Y = Yellow

then i can do linear in four sections. I think
Logged

"Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent di

Pages: [1]   Go Up
Jump to: