#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
const int pinR = 6;
const int pinG = 5;
const int pinB = 3;
const int potB = A0;
const int potG = A1;
const int potR = A2;
void setup() {
pinMode(pinR, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(potR, INPUT);
pinMode(potG, INPUT);
pinMode(potB, INPUT);
lcd.begin(20, 4);
lcd.print("RGB! Use sliders to change values");
}
int readPot(int pin) {
return map(analogRead(pin), 0, 1023, 0, 255);
}
void loop() {
analogWrite(pinR, readPot(potR));
analogWrite(pinG, readPot(potG));
analogWrite(pinB, readPot(potB));
}