#include <LiquidCrystal_I2C.h> // https://github.com/johnrickman/LiquidCrystal_I2C
#define I2C_ADDR 0x27 // LCD IIC ADDRESS
#define LCD_COLS 20 // LCD columns
#define LCD_ROWS 4 // LCD rows
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLS, LCD_ROWS); // create the lcd object
char text[] = "<DVD>"; // text object
byte size = sizeof(text), rowDir = 1, colDir = 1, col, row; // location and direction of movement
int wait = 250; // speed control
void setup() {
randomSeed(analogRead(A0));
lcd.init(); // start lcd object
lcd.backlight(); // turn backlight on
row = random(1, LCD_ROWS); // start inside row limits
col = random(1, LCD_COLS - size); // start inside column limits
}
void loop() {
dvd();
}
void dvd() {
if (row == (LCD_ROWS - 1) || row == 0) // check for borders
rowDir = -rowDir; // change direction
if (col == (LCD_COLS - size + 1) || col == 0) // check for borders
colDir = -colDir; // change direction
lcd.setCursor(col, row); // set new cursor location
lcd.print(text); // display text
delay(wait); // speed control
lcd.setCursor(col, row); // re-set cursor location
for (int i = 0; i < size; i++) // count spaces
lcd.print(" "); // cover text
row += rowDir; // increment row
col += colDir; // increment col
}