I am building a pressure sensor that controls RGB lED's. I want to be able to get a smooth transition from blue (light pressure) to green (medium pressure) up to red (highest pressure) and am having trouble with the code.

void setup() { pinMode(REDLED, OUTPUT); //tell Arduino LED is an output pinMode(BLUELED, OUTPUT); //tell Arduino LED is an output pinMode(GREENLED, OUTPUT); //tell Arudino LED is an output pinMode(POT1, INPUT); //tell Arduino LED is an output

First question is why is Serial.begin() in loop()? That statement belongs in setup(), since it only should be called once.

Second question is whether you have any idea what values the sensor actually returns. The normal range of values in brt would be from 0 to 1023. That would give blueval a value in the range 250 to -5. Not all values in that range are valid PWM values.

The valuation of greenval is a bit strange. If the value in brt is greater than or equal to 0 (it always will be) OR it is less than 500, set greenval to half of brt, which gives greenval a range of values from 0 to 512. Not all values in that range are valid PWM values. I think you wanted AND (&&) in that statement, not OR (||).

So, what is the LED doing that you don't want, or not doing that you do want?

PS> I hope you know that the eye won't perceive any kind of linear transition from blue to red as the pressure on the sensor increases. The eye does not perceive green as being any kind of intermediary value between blue and red.

When I originally tested my pressure sensor, it didn't seem to get above a 1000 range, so I set it from 0-1000. What I want the color to represent is the amount of pressure that is on the sensor, so I want blue to be in the range of light pressure, green to be the middle pressure color and red to be the one with the highest amount of pressure at the (1000) point.In other words at 0, blue=250;at 500, green=250;at 1000, red = 250;

For a range of values that is supposed to span from 0 to 1023, that is a very small range of values. I would only expect blueval to contain a significant enough value to cause any visible light to appear.

What happens if you really mash on the sensor? Do the readings get significant?