#include <Wire.h>;
#include <LiquidCrystal_I2C.h>;
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
int const ledR = 11;
int const ledG = 10;
int const ledB = 9;
int const PotR = A0;
int const PotG = A1;
int const PotB = A2;
int lecR;
int porcR;
int lecG;
int porcG;
int lecB;
int porcB;
void setup() {
pinMode(ledR, OUTPUT);
pinMode(ledG, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(PotR, OUTPUT);
pinMode(PotG, OUTPUT);
pinMode(PotB, OUTPUT);
LCD.init();
LCD.backlight();
LCD.setCursor(0, 0);
}
void loop() {
// Led roja
lecR = analogRead(PotR);
porcR = map(lecR, 0, 1023, 0, 254);
analogWrite(ledR, porcR);
LCD.setCursor(0, 0);
LCD.print("LedR:");
LCD.setCursor(5, 0);
LCD.print(porcR);
// Led verde
lecG = analogRead(PotG);
porcG = map(lecG, 0, 1023, 0, 254);
analogWrite(ledG, porcG);
LCD.setCursor(8, 0);
LCD.print("LedG:");
LCD.setCursor(13, 0);
LCD.print(porcG);
// Led azul
lecB = analogRead(PotB);
porcB = map(lecB, 0, 1023, 0, 254);
analogWrite(ledB, porcB);
LCD.setCursor(0, 1);
LCD.print("LedB:");
LCD.setCursor(5, 1);
LCD.print(porcB);
}