Go Down

#### fliggygeek

##### Jan 22, 2011, 07:20 amLast Edit: Jan 22, 2011, 07:20 am by fliggygeek Reason: 1
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?

#### PaulS

#1
##### Jan 22, 2011, 01:26 pm
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.

#### fliggygeek

#2
##### Jan 23, 2011, 03:19 pm
if I use a simple setup of this(intermediate values removed)
 P W Y W W W R W B

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

then i can do linear in four sections. I think

Go Up