Monday, September 23, 2024

I2C LCD Scrolling Display

 #include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address to 0x27 for a 16 chars and 2 line display

void setup() {
  lcd.init();         // Initialize the LCD
  lcd.backlight();    // Turn on the LCD screen backlight
}

void loop() {
  // Message to scroll
  String message = "Hello World.! Sunil Singh ";
  int messageLength = message.length();

  // Scroll the message across the LCD
  for (int pos = 0; pos < messageLength; pos++) {
    lcd.clear(); // Clear the LCD for each new position
    lcd.setCursor(0, 0); // Set cursor to the first line
    lcd.print(message.substring(pos, pos + 16)); // Print 16 characters
    delay(300); // Delay for a smoother scroll
  }

  // Short delay before next message
  delay(1000);

  // Now display another message
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("This is a LCD");   // First line
  lcd.setCursor(0, 1);
  lcd.print("Screen Test");      // Second line
  delay(3000); // Display for 3 seconds
}


No comments:

Post a Comment

MUD Three Mode operation Manual Automatic GPS

 Code for three mode operation: /*   3-Mode Headlight Controller   - Manual mode (driver uses a toggle to pick high/low)   - Auto mode (LDR...