LCD I2C
print text on a LCD_1602A panel
hardware
- Arduino board
- LCD 1602A board
wire
- jump the led on the back
- A4 SDA
- A5 SCL
- adjust Potentiometer when screen has 16 bars, 50% grey
code
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
char array1[] = " Arduino ";
char array2[] = "Hello, World ";
int tim = 500;
// set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27,16,2);
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
}
void loop() {
// put your main code here, to run repeatedly:
lcd.setCursor(15,0); // set the cursor to column 15, line 0
for (int i = 0; i<26; i++) {
lcd.scrollDisplayLeft(); // Scrolls the contents of the display one space to the left.
lcd.print(array1[i]); // print a message to the LCD
delay(tim); // wait for 250 microseconds
}
lcd.clear(); // Clears the LCD screen and positions the cursor in the uppoer-left corner.
lcd.setCursor(15,1);
for (int j=0; j<26; j++) {
lcd.scrollDisplayLeft();
lcd.print(array2[j]);
delay(tim);
}
lcd.clear();
}