Skip to content

Commit b332904

Browse files
committed
Modified LCD custom character example
moved lcd.begin() to the beginnng of the setup() and fixed an issue that prevented the example from compiling. When calling lcd.write() with an argument of 0, the 0 must be cast a s a byte.
1 parent 83ef181 commit b332904

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

libraries/LiquidCrystal/examples/CustomCharacter/CustomCharacter.ino

+9-7
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
* wiper to LCD VO pin (pin 3)
2323
* 10K poterntiometer on pin A0
2424
25-
created21 Mar 2011
25+
created 21 Mar 2011
2626
by Tom Igoe
27+
modified 11 Nov 2013
28+
by Scott Fitzgerald
29+
2730
Based on Adafruit's example at
2831
https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde
2932
@@ -96,7 +99,11 @@ byte armsUp[8] = {
9699
0b00100,
97100
0b01010
98101
};
102+
99103
void setup() {
104+
// initialize LCD and set up the number of columns and rows:
105+
lcd.begin(16, 2);
106+
100107
// create a new character
101108
lcd.createChar(0, heart);
102109
// create a new character
@@ -108,11 +115,9 @@ void setup() {
108115
// create a new character
109116
lcd.createChar(4, armsUp);
110117

111-
// set up the lcd's number of columns and rows:
112-
lcd.begin(16, 2);
113118
// Print a message to the lcd.
114119
lcd.print("I ");
115-
lcd.write(0);
120+
lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte
116121
lcd.print(" Arduino! ");
117122
lcd.write(1);
118123

@@ -133,6 +138,3 @@ void loop() {
133138
lcd.write(4);
134139
delay(delayTime);
135140
}
136-
137-
138-

0 commit comments

Comments
 (0)