1
1
#include < LiquidCrystal_PCF8574.h>
2
2
#include < Wire.h>
3
3
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
5
5
6
6
int show = -1 ;
7
7
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 () {
10
16
int error;
11
17
12
18
Serial.begin (115200 );
@@ -16,7 +22,7 @@ void setup()
16
22
while (!Serial)
17
23
;
18
24
19
- Serial.println (" Dose: check for LCD " );
25
+ Serial.println (" Probing for PCF8574 on address 0x27... " );
20
26
21
27
// See http://playground.arduino.cc/Main/I2cScanner how to test for a I2C device.
22
28
Wire.begin ();
@@ -28,17 +34,19 @@ void setup()
28
34
if (error == 0 ) {
29
35
Serial.println (" : LCD found." );
30
36
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);
32
41
33
42
} else {
34
43
Serial.println (" : LCD not found." );
35
- } // if
44
+ } // if
36
45
37
- } // setup()
46
+ } // setup()
38
47
39
48
40
- void loop ()
41
- {
49
+ void loop () {
42
50
if (show == 0 ) {
43
51
lcd.setBacklight (255 );
44
52
lcd.home ();
@@ -96,10 +104,16 @@ void loop()
96
104
lcd.clear ();
97
105
lcd.print (" write-" );
98
106
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 {
100
114
lcd.print (show - 13 );
101
- } // if
115
+ } // if
102
116
103
117
delay (1400 );
104
118
show = (show + 1 ) % 16 ;
105
- } // loop()
119
+ } // loop()
0 commit comments