The characters on the display 1602 using the LiquidCrystal library are displayed in black, but if you exclude the string lcd.begin (16,2), the color of the characters is not black, but white.
The code that displays on my shield 1602 is first white text, then black:
#include <LiquidCrystal.h>
LiquidCrystal lcd (4, 5, 6, 7, 11, 12);
void setup () {
lcd.print ("White text");
delay (3000);
lcd.begin (16,2);
lcd.clear ();
lcd.print ("Black text");
}
void loop () {}
How to correctly adjust the color of characters?
Without the begin() function, the display is not initialized. For all practical purposes, as far as the Arduino is concerned, the display does not exist. Whatever you send to the display before the begin() are not printed. There are no colors for the characters, black only. You can adjust the contrast to make the characters more clearly visible.
Your last sentence is correct, the others ... not so much.
The display is initialized when the power is applied. The problem is that the default initialization is for a display that uses only one line of display memory and those are quite rare, essentially being limited to some of the 16x1 type displays. Other displays, such as the 16x2 will work, sort of, on the first row only.
Without the begin() function the default initialization is not overwritten so your 16x2 will only display text on the upper row. Also if the contrast is adjusted at this point it will be incorrectly set for the display after the begin() function is run.
The displays with a greenish background (when unpowered) display black characters. The displays with a blue background display white characters when properly initialized.
Bill lives one time zone west of me. He will probably be along soon with a more detailed explanation.
Don
Actually, when using the LiquidCrystal library there are 3 different initializations:
- when the LCD is powered up. (pushing reset does not do this)
- when the constructor is processed - which is before setup() is called
- when begin() is called by the sketch.
Each puts the display in a different state.
After #1 the display will be in 8 bit, 1 line display, 5x8 font, mode.
#2 (the constructor) will put the display in 8bit or 4 bit mode (depending on parameters), 1 line display, 5x8 font mode.
which ensures the the sketch can talk to the LCD
#3 begin() will reinitialize the LCD interface mode to 8bit or 4 bit mode (depending on constructor parameters), 1 or 2 line mode depending on number of rows, and 5x8 font mode.
In that sketch, as Don said, the first print happens in 1 line mode, the 2nd print happens in 2 line mode which on a 2 line display can cause issues.