Skip to content

Commit 9a788c1

Browse files
committed
Example now includes 2 custom characters
1 parent a61ebb2 commit 9a788c1

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

examples/LiquidCrystal_PCF8574_Test/LiquidCrystal_PCF8574_Test.ino

+26-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#include <LiquidCrystal_PCF8574.h>
22
#include <Wire.h>
33

4-
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
4+
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
55

66
int show = -1;
77

8-
void setup()
9-
{
8+
// 2 custom characters
9+
10+
byte dotOff[] = { 0b00000, 0b01110, 0b10001, 0b10001,
11+
0b10001, 0b01110, 0b00000, 0b00000 };
12+
byte dotOn[] = { 0b00000, 0b01110, 0b11111, 0b11111,
13+
0b11111, 0b01110, 0b00000, 0b00000 };
14+
15+
void setup() {
1016
int error;
1117

1218
Serial.begin(115200);
@@ -16,7 +22,7 @@ void setup()
1622
while (!Serial)
1723
;
1824

19-
Serial.println("Dose: check for LCD");
25+
Serial.println("Probing for PCF8574 on address 0x27...");
2026

2127
// See http://playground.arduino.cc/Main/I2cScanner how to test for a I2C device.
2228
Wire.begin();
@@ -28,17 +34,19 @@ void setup()
2834
if (error == 0) {
2935
Serial.println(": LCD found.");
3036
show = 0;
31-
lcd.begin(16, 2); // initialize the lcd
37+
lcd.begin(16, 2); // initialize the lcd
38+
39+
lcd.createChar(1, dotOff);
40+
lcd.createChar(2, dotOn);
3241

3342
} else {
3443
Serial.println(": LCD not found.");
35-
} // if
44+
} // if
3645

37-
} // setup()
46+
} // setup()
3847

3948

40-
void loop()
41-
{
49+
void loop() {
4250
if (show == 0) {
4351
lcd.setBacklight(255);
4452
lcd.home();
@@ -96,10 +104,16 @@ void loop()
96104
lcd.clear();
97105
lcd.print("write-");
98106

99-
} else if (show > 12) {
107+
} else if (show == 13) {
108+
lcd.clear();
109+
lcd.print("custom 1:<\01>");
110+
lcd.setCursor(0, 1);
111+
lcd.print("custom 2:<\02>");
112+
113+
} else {
100114
lcd.print(show - 13);
101-
} // if
115+
} // if
102116

103117
delay(1400);
104118
show = (show + 1) % 16;
105-
} // loop()
119+
} // loop()

0 commit comments

Comments
 (0)