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);
}