|

Effect LCD I2C 20×4 Fly In Out Arduino

LCD Effect 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 20×4 LCD I2C. For the basic circuit and code you can read the article LCD 20×4 Arduino I2C Code Basic Tutorial.

Video

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.

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. I hope this Fly In Out Effect LCD I2C 20×4 Arduino article is useful.

Similar Posts