//**********************************************
//* *
//* Name:Dylan Dunn *
//* Program Name:PWN LCD FADER AH.ino *
//* Date:3/23/2023 *
//* Desc:Lightchaser with potentiometer & LCD *
//* *
//**********************************************
#include <LiquidCrystal_I2C.h>. //including lcd
#define I2C_ADDR 0x27 //graphics for
#define LCD_COLUMNS 16 // width
#define LCD_LINES 2 //length
LiquidCrystal_I2C lcd (I2C_ADDR, LCD_COLUMNS, LCD_LINES); //parameters for lcd
int redLED = 6; //pin for red LED
int greenLED = 5; //pin for green LED
int blueLED = 3; //pin for blue LED
int redPot = A0; // pin control red LED
int greenPot = A1; //pin control green LED
int bluePot = A2; //pin control blue LED
int blue = 0; //value for blue LED
int red = 0; //value for red LED
int green = 0; // value for green LED
void setup() {
lcd.init(); // initializing lcd
lcd.backlight(); // turn on blacklight
lcd.setCursor(0, 0); // set cursor
lcd.print("*LED FADER v1.0*"); //print message wanted
pinMode(redLED, OUTPUT); //output for red LED
pinMode(greenLED, OUTPUT); //output for green LED
pinMode(blueLED, OUTPUT); //output for blue LED
analogWrite(redLED, 255); // redLED off
analogWrite(greenLED, 255); //greenLED off
analogWrite(blueLED, 255); //blueLED off
delay (2000); //2000 ms delay
lcd.setCursor(0,0); //setCursor
lcd.print("RED GRN BLU "); //print message wanted
}
void loop() {
red = (analogRead(redPot) / 4); //limitation of 255 for red
lcd.setCursor(0,1); //location value for redLED
lcd.print(red); //print RGB value for red
green = (analogRead(greenPot) / 4); //limitation of 255 for green
lcd.setCursor(6,1); //location value for greenLED
lcd.print(green); //print RGB value for green
blue = (analogRead(bluePot) / 4); //limitation of 255 for blue
lcd.setCursor(12,1); // location value for blueLED
lcd.print(blue); //print RGB value for blue
analogWrite(blueLED , blue); //RGB value for blue
analogWrite(redLED , red); //RGB value for red
analogWrite(greenLED , green); //RGB value for green
lcd.setCursor(0, 1); //value location
}