Skip to content Skip to sidebar Skip to footer

Make Fly In Out Effect LCD I2C 20x4 Arduino Code

Fly In / Fly Out Effect LCD I2C Arduino

Make Fly In Out Effect LCD I2C Arduino Code - Previously I had created a character typing effect. Now I want to share the program code how to make the text effect fly in and then fly out.

For communication between arduino board and LCD, I use arduino 20x4 LCD I2C. For the basic circuit and code you can read the article LCD 20x4 Arduino I2C Code Basic Tutorial.

You can see the Fly In and Fly Out effects in the following video:


The program code is as follows. Please copy and paste it into your Arduino IDE. Then upload the code to your board.

Program Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F, 20, 4);

char array1[] = " www.chippiko.com";
int startPoint;
int endPoint;
int i, j;
int delays = 60;


void setup() {
  lcd.init();
  lcd.backlight();
}

void loop() {
  lcd.clear();

  //Fly In Effect
  endPoint = sizeof (array1) ;
  for (i = sizeof (array1) - 2; i >= 0; i--)
  {
    startPoint = 0;

    for (j = 0; j < endPoint; j++)
    {
      lcd.setCursor(startPoint, 0);
      lcd.print(array1[i]);
      delay(delays);

      if (startPoint != endPoint - 1) {
        lcd.setCursor(startPoint, 0);
        lcd.print(' ');
      }
      startPoint++;
    }
    endPoint--;

  }
  delay(1000);

  //Fly Out Effect
  endPoint = 19 ;
  for (i = sizeof (array1) - 1; i > 0; i--)
  {
    startPoint =  i;

    for (j = 0; j < (endPoint - i); j++)
    {
      lcd.setCursor(startPoint, 0);
      lcd.print(array1[i - 1]);
      delay(delays);

      if (startPoint != endPoint) {
        lcd.setCursor(startPoint, 0);
        lcd.print(' ');
        startPoint++;
      }

      if (startPoint == endPoint)
      {
        lcd.setCursor(endPoint, 0);
        lcd.print(' ');
      }
    }
  }
  delay(1000);


}

Done.

Post a Comment for "Make Fly In Out Effect LCD I2C 20x4 Arduino Code"