To display text with a (fade-in) effect on an (LCD screen) connected to an Arduino Uno using an I2C converter
Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address and the number of columns and rows
int fadeDelay = 20; // Delay for each fade step (in milliseconds)
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
lcd.setCursor(0, 0); // Set the cursor to the start of the first row
lcd.print(“Free Palestine”); // Your initial text
}
// ██████╗ ███████╗██╗███████╗███████╗ ██████╗ ██████╗ ███╗ ███╗ //██╔═████╗██╔════╝██║██╔════╝██╔════╝ ██╔════╝██╔═══██╗████╗ ████║ //██║██╔██║███████╗██║█████╗ █████╗ ██║ ██║ ██║██╔████╔██║ //████╔╝██║╚════██║██║██╔══╝ ██╔══╝ ██║ ██║ ██║██║╚██╔╝██║ //╚██████╔╝███████║██║███████╗██║ ██╗ ╚██████╗╚██████╔╝██║ ╚═╝ ██║ // ╚═════╝ ╚══════╝╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝
void loop() {
lcd.setCursor(0, 1); // Set the cursor to the second row
// Your text
String text = “Pray For Palestine”;
// Fade in the backlight
for (int brightness = 0; brightness < 256; brightness++) {
lcd.setBacklight(brightness); // Set backlight brightness
delay(fadeDelay);
}
// ▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄ ▄▄ // ▐░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░▌ ▐░░▌ //▐░█░█▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▀▀▀▀█░█▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░▌░▌ ▐░▐░▌ //▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌▐░▌ ▐░▌▐░▌ //▐░▌ ▐░▌ ▐░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▐░▌ ▐░▌ //▐░▌ ▐░▌ ▐░▌▐░░░░░░░░░░░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ //▐░▌ ▐░▌ ▐░▌ ▀▀▀▀▀▀▀▀▀█░▌ ▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌ ▐░▌▐░▌ ▀ ▐░▌ //▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ //▐░█▄▄▄▄▄█░█░▌ ▄▄▄▄▄▄▄▄▄█░▌ ▄▄▄▄█░█▄▄▄▄ ▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▄ ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌ // ▐░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌ // ▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀
// Display the text
lcd.print(text);
// Delay to keep the text visible
delay(1000);
// Fade out the backlight
for (int brightness = 255; brightness >= 0; brightness–) {
lcd.setBacklight(brightness); // Set backlight brightness
delay(fadeDelay);
}
// Clear the text
lcd.clear();
}
// ██████ ███████ ██ ███████ ███████ ██████ ██████ ███ ███ //██ ████ ██ ██ ██ ██ ██ ██ ██ ████ ████ //██ ██ ██ ███████ ██ █████ █████ ██ ██ ██ ██ ████ ██ //████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ // ██████ ███████ ██ ███████ ██ ██ ██████ ██████ ██ ██
0sief