// RGB and R, G, B LED demo with ESP32
const int pinR = 12;
const int pinG = 14;
const int pinB = 27;
const int potR = 32;
const int potG = 33;
const int potB = 35;
void setup() {
pinMode(pinR, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(potR, INPUT);
pinMode(potG, INPUT);
pinMode(potB, INPUT);
}
int readPot(int pin) {
return map(analogRead(pin), 0, 4095, 0, 255);
}
void loop() {
analogWrite(pinR, readPot(potR));
analogWrite(pinG, readPot(potG));
analogWrite(pinB, readPot(potB));
}