#define pinR 4
#define pinG 2
#define pinB 15
#define potR 13
#define potB 12
#define potG 14
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(potR, INPUT);
pinMode(potG, INPUT);
pinMode(potB, INPUT);
pinMode(pinR, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(pinB, OUTPUT);
}
void loop() {
int valueR = analogRead(potR);
int valueG = analogRead(potG);
int valueB = analogRead(potB);
int R = map(valueR,0,4095,0,255);
int G = map(valueG,0,4095,0,255);
int B = map(valueB,0,4095,0,255);
setColor(R, G, B);
Serial.print("Color :");
Serial.print(R);Serial.print(",");
Serial.print(G);Serial.print(",");
Serial.println(B);
delay(1000);
}
void setColor(int red, int green, int blue) {
analogWrite(pinR, red);
analogWrite(pinG, green);
analogWrite(pinB, blue);
}