#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_LINES 4
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
const int pinR = 6;
const int pinG = 5;
const int pinB = 3;
int potpinR = 2;
int valR;
int potpinG = 1;
int valG;
int potpinB = 0;
int valB;
void setup() {
pinMode(pinR, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(pinB, OUTPUT);
lcd.init();
lcd.backlight();
}
void loop() {
valR = analogRead(potpinR);
valG = analogRead(potpinG);
valB = analogRead(potpinB);
valR = map(valR, 0, 1023, 0, 255);
valG = map(valG, 0, 1023, 0, 255);
valB = map(valB, 0, 1023, 0, 255);
analogWrite(pinR, valR);
analogWrite(pinG, valG);
analogWrite(pinB, valB);
lcd.setCursor(1, 0);
lcd.print("R: ");
if (valR < 10) {
lcd.print("00");
} else if(valR < 100 && valR >= 10) {
lcd.print("0");
}
lcd.print(valR);
lcd.setCursor(8, 0);
lcd.print("G: ");
if (valG < 10) {
lcd.print("00");
} else if(valG < 100 && valG >= 10) {
lcd.print("0");
}
lcd.print(valG);
lcd.setCursor(5, 1);
lcd.print("B: ");
if (valB < 10) {
lcd.print("00");
} else if(valB < 100 && valB >= 10) {
lcd.print("0");
}
lcd.print(valB);
}