Here is a non-float, hue only version also. What is the application? It sounds like it could be interesting.
void setup(){
Serial.begin(9600);
}
void loop(){
//colors out of phase by 341 (1023/3)
Serial.println("V,R,G,B");
for(int v = 0; v < 1024; v++){ //analogRead surrogate
Serial.print(v);
Serial.print(",");
Serial.print(colVal(v+341),DEC); //red
Serial.print(",");
Serial.print(colVal(v),DEC); //green
Serial.print(",");
Serial.println(colVal(v+682),DEC); //blue
}
while(true);
}
//based on green hue function, add phase adjustment for red or blue value
byte colVal(int val){
int v = val % 1024;
if(v<=170)
return (v * 3) / 2;
if(v<=512)
return 255;
if(v<=682)
return 255 - (((v%171) * 3) / 2);
return 0;
}
Edit: Just noticed the part about non-floats messing up the pwm functions, that doesn't sound right.