#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int pinR = 3;
const int pinG = 5;
const int pinB = 6;
const int potR = A0;
const int potG = A1;
const int potB = A2;
LiquidCrystal_I2C lcd(0x27, 20, 4); 
void setup() {
  pinMode(pinR, OUTPUT);
  pinMode(pinG, OUTPUT);
  pinMode(pinB, OUTPUT);
  pinMode(potR, INPUT);
  pinMode(potG, INPUT);
  pinMode(potB, INPUT);
  lcd.begin(20, 4);
}

int readPot(int pin) {
  return map(analogRead(pin), 1023, 0, 0, 255);
}

void loop() {
  float r=analogRead(potR);
  float g=analogRead(potG);
  float b=analogRead(potB);
  analogWrite(pinR, readPot(potR));
  analogWrite(pinG, readPot(potG));
  analogWrite(pinB, readPot(potB));
  lcd.setCursor(0, 0);
  lcd.print("Red:       ");
  lcd.setCursor(0, 1);
  lcd.print("Green:     ");
  lcd.setCursor(0, 2);
  lcd.print("Blue:      ");
  lcd.setCursor(7, 0);
  lcd.print(r, 0);
  lcd.setCursor(7, 1);
  lcd.print(g, 0);
  lcd.setCursor(7, 2);
  lcd.print(b, 0);
  delay(2000);
}