const int REDPIN = 4;
const int GREENPIN = 3;
const int BLUEPIN = 2;
const int REDPOTI = A5;
const int GREENPOTI = A6;
const int BLUEPOTI = A7;
int rPotiVal, gPotiVal, bPotiVal;
void setup() {
// put your setup code here, to run once:
pinMode(REDPIN, OUTPUT);
pinMode(GREENPIN, OUTPUT);
pinMode(BLUEPIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
rPotiVal = analogRead(REDPOTI);
gPotiVal = analogRead(GREENPOTI);
bPotiVal = analogRead(BLUEPOTI);
setColor(rPotiVal, gPotiVal, bPotiVal);
delay(1000);
}
void setColor(int red, int green, int blue) {
red = red/4;
green = green/4;
blue = blue/4;
Serial.print("rgb(");
Serial.print(red);
Serial.print(",");
Serial.print(green);
Serial.print(",");
Serial.print(blue);
Serial.println(")");
analogWrite(REDPIN, red);
analogWrite(GREENPIN, green);
analogWrite(BLUEPIN, blue);
}