// ****************************************
// * *
// * NAME : Cayo Colin Carbonaro *
// * Program name : LedFader.ino *
// * DATE : 2023-02-13 *
// * Desc : LED Fader with controlable *
//* color and displays values *
// * *
// ****************************************
#include <LiquidCrystal_I2C.h>. // sets up the library
#define I2C_ADDR 0x27 // Configures the LCD display
#define LCD_COLUMNS 16 // Configures the LCD display
#define LCD_LINES 2 // Configures the LCD display
LiquidCrystal_I2C lcd (I2C_ADDR, LCD_COLUMNS, LCD_LINES); //creates an "lcd" object with above defined parameters
int red = 6; // sets a variable for the red pin
int green = 5; // sets a variable for the green pin
int blue = 3; // sets a variable for the blue pin
int redR = A0; // sets a variable for the blue potentiometer
int greenR = A1; // sets a variable for the green potentiometer
int blueR = A2; // sets a variable for the red potentiometer
void setup() {
pinMode(red, OUTPUT); // configs the red pin to an OUTPUT
pinMode(green, OUTPUT); // configs the green pin to an OUTPUT
pinMode(blue, OUTPUT); // configs the blue pin to an OUTPUT
lcd.init(); // initialize the lcd display
lcd.backlight(); // initialize the lcd display
lcd.setCursor(0, 0); // sets the cursor to the top left
lcd.print("*LED FADER v1.0*"); // displays title
delay(1000); // keeps title up for a second
lcd.clear(); // Clears the title
}
void loop() {
int redVal = analogRead(redR)/4; // reads the red potentiometer and divides the value by 4
int grnVal = analogRead(greenR)/4; // reads the green potentiometer and divides the value by 4
int bluVal = analogRead(blueR)/4; // reads the blue potentiometer and divides the value by 4
analogWrite(red, redVal); // pulses the red wire at the rate of redVal
analogWrite(green, grnVal); // pulses the red wire at the rate of grnVal
analogWrite(blue, bluVal); // pulses the red wire at the rate of bluVal
lcd.print("Red Grn Blu "); // displays on the top of lcd the names of the colors
lcd.setCursor(0, 1); // sets the cursor to column 1, line 2
lcd.print(redVal); // displays redVal
lcd.setCursor(6, 1); // sets the cursor to column 7, line 2
lcd.print(grnVal); // displays grnVal
lcd.setCursor(12, 1); // sets the cursor to column 13, line 2
lcd.print(bluVal); // displays blueVal
lcd.print(" "); // adds space to make display un cluterd
delay (100); // delay for 1 tenth of a second
} // ends loop