#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 columns and 2 rows
// Pin definitions for the RGB LED
#define RED_PIN 25
#define GREEN_PIN 26
#define BLUE_PIN 27
void setup() {
// Initialize the LCD
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
lcd.clear();
lcd.setCursor(0, 0); // Set the cursor to the first column of the first row
lcd.print("HALLO SEMUA"); // Print a welcome message
delay(2000); // Wait for 2 seconds
// Initialize RGB LED pins as output
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
}
void loop() {
// Cycle through RGB LED colors with messages on the LCD
// Red
setColor(255, 0, 0);
updateLCD("RED Color");
delay(1000);
// Green
setColor(0, 255, 0);
updateLCD("GREEN Color");
delay(1000);
// Blue
setColor(0, 0, 255);
updateLCD("BLUE Color");
delay(1000);
}
// Function to set RGB color
void setColor(int red, int green, int blue) {
analogWrite(RED_PIN, red);
analogWrite(GREEN_PIN, green);
analogWrite(BLUE_PIN, blue);
}
// Function to update the LCD with the current color
void updateLCD(const char* message) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(message);
}