//*********************************************
//* *
//* Name Logan Dinnendahl *
//* Program name PWM LED Fader (part one) *
//* Date 2023-03-21 *
//* Desc light chaser with *
//* potentiometers and LCD *
//* *
//*********************************************
#include <LiquidCrystal_I2C.h> // Includes LCD in the progra,
#define I2C_ADDR 0x27 // Defining graphics for LCD...
#define LCD_COLUMNS 16
#define LCD_LINES 2
LiquidCrystal_I2C lcd (I2C_ADDR, LCD_COLUMNS, LCD_LINES);
int redLED = 6; // Pin for red LED
int greenLED = 5; // Pin for green LED
int blueLED = 3; // Pin for blue LED
int redPot = A0; // Position for Red Potentiometer
int greenPot = A1; // Position for Green Potentiometer
int bluePot = A2; // Position for Blue Potentiometer
int blue = 0; // Value that will be printed on the LCD
int green = 0; // Value that will be printed on the LCD
int red = 0; // Value that will be printed on the LCD
void setup() {
lcd.init(); // intilizing LCD screen
lcd.backlight(); // Turn on backlight
lcd.setCursor(0, 0); // set cursor
lcd.print("*LED FADER v1.0*"); // Printing message
pinMode(redLED, OUTPUT); // Setup for red pin
pinMode(greenLED, OUTPUT); // Setup for green pin
pinMode(blueLED, OUTPUT); // Setup for blue pin
analogWrite(redLED, 225); // 0 = ON 225 = OFF...
analogWrite(greenLED, 225);
analogWrite(blueLED, 225);
delay (2000); // Delay for LCD startup screen
lcd.setCursor (0, 0); // Writing position
lcd.print ("RED GRN BLU "); // Printing message
}// end setup()
void loop() {
blue = (analogRead(bluePot ) /4); // Converting analog values into RGB...
red = (analogRead(redPot ) /4);
green= (analogRead(greenPot ) /4);
analogWrite(blueLED , blue); // Deciding the value of the LEDs...
analogWrite(redLED , red);
analogWrite(greenLED, green);
lcd.setCursor(0, 1); // Position of Writing
lcd.print (red); // Printing Red Value
lcd.setCursor(6, 1); // Position of Writing
lcd.print (green); // Printing Green Value
lcd.setCursor(12, 1); // Position of Writing
lcd.print (blue); // Printing Blue Value
} // end void loop