Potentiometer controlled RGB fade without using serial

is there a way to use a potentiometer to control an RBG fade thought Arduino without using and type of serial command. the code below only semi works. how can i chage the code to fade smoothly through the whole color spectrum?

// BlinkM / BlinkM MinM pins
const int redPin = 3;  
const int grnPin = 4; 
const int bluPin = 1;  
const int sclPin = 2;  

const int knobPin  = sclPin;

int pos;


void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(grnPin, OUTPUT);
  pinMode(bluPin, OUTPUT);


  pinMode(knobPin, INPUT);

}

void loop() {

  pos = analogRead( knobPin ); 

  
  int redValue = constrain(map(pos, 0, 512, 255, 0),0,255); 

  int greenValue = constrain(map(pos, 0, 512, 0, 255),0,255)-constrain(map(pos, 512, 1023, 0, 255),0,255);  

  int blueValue = constrain(map(pos, 512, 1023, 0, 255),0,255); 


 

  analogWrite(redPin, redValue);

  analogWrite(grnPin, greenValue);

  analogWrite(bluPin, blueValue);
}

is there a way to use a potentiometer to control an RBG fade thought Arduino without using and type of serial command. the code below only semi works. how can i chage the code to fade smoothly through the whole color spectrum?

Yes, possible but not trivial and not 100% . There is a problem as the RGB color space is not "the whole colorspectrum". In fact the colorspectrum is 3 dimensional and with your potmeter you can only control one dimension. To control the color along the rainbow (spectrum) you need the LAB color space - CIELAB color space - Wikipedia - or the HSL colorspace and convert it to RGB values. BUt this RGB is device dependant.

That said you can approximate the needed conversion quite well, for some formulas see - http://www.easyrgb.com/index.php?X=MATH -

Try the HSL to RGB first

I dont even know where to start with writing that into my program...

I'm pretty sure there is example code for HSL to RGB somewhere; have you tried the Playground?

found this one - http://www.dipzo.com/wordpress/?p=50 - need a rewrite a bit to read from potmeter iso rotary encoder

Seems to work quite well

found this one - http://www.dipzo.com/wordpress/?p=50 - need a rewrite a bit to read from potmeter iso rotary encoder

Seems to work quite well

The problem i am having is that anything that has "serial" in it, i will always get an error.

What error are you getting when you try the serial interface? Like in this thread?
http://arduino.cc/forum/index.php/topic,67519.0.html
If so, reply#10 in that thread had the solution for me.

I've done something similar when designing a character creator for a game - a slider that selects hue. I split the bar up into red->red+green, red+green->green, green->green+blue, green+blue->blue, blue->red+blue, red+blue->red and made each section linear interpolate. Worked quite nicely.

Have you tried spelling it 'Serial'?