Sample code 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include
#include
#include
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity
void setup()
{
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print(“Hello world!”);
lcd.setCursor(0, 1);
lcd.print(“Row number: “);
lcd.setCursor(12, 1);
lcd.print(“2”);
}
void loop()
{
}
Sample code 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include
#include
#include
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity
void setup()
{
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(0, 0); //First column, first row
lcd.print(“Hello world!”);
lcd.setCursor(0, 1); //First column, second row
lcd.print(“Row number: “);
lcd.setCursor(12, 1); //12th column, second row
lcd.print(“2”);
lcd.blink(); //start blinking cursor
delay (3000); //delay 3 seconds
}
void loop()
{
demoDisplay();
}
void demoDisplay()
{
lcd.clear(); // clear display, set cursor position to zero
lcd.setBacklight(HIGH); // Backlight on
lcd.setCursor (0,0); //col 0 of line 1
lcd.print(“Boot sequence”);
lcd.setCursor (0,1); // go col 0 of line 2
lcd.print(“starting.”);
lcd.noBlink(); //stop blinking cursor
delay(1000); //delay 1 second
wipeLines(); //run function wipeLines
}
void wipeLines() {
for (int y = 0; y for (int x = 0; x lcd.setCursor (x,y);
lcd.print(” “);
delay(10);
}
}
}