C
LCD
.
OMMON
COMMANDS
5: BASIC Stamp Command Reference – LCDCMD
shown above. This process is known as initializing the LCD and is the
first thing your program should do upon starting up. The following code
is a good example of LCD initialization.
InitLCD:
PAUSE 1000
LCDCMD 1, 48
PAUSE 10
LCDCMD 1, 48
PAUSE 1
LCDCMD 1, 48
PAUSE 1
LCDCMD 1, 32
LCDCMD 1, 40
LCDCMD 1, 8
LCDCMD 1, 12
LCDCMD 1, 6
LCDCMD 1, 1
This initialization code is the most commonly used sequence for a 2 x 16
and 4 x 20 LCD display (the 2-line mode instruction sets the 4 x 20 to 4-line
mode). The PAUSE 1000 command is optional, but only if your program
takes more than approximately 700 ms before it executes the InitLCD code
above. Without it, upon powering your circuit, the BASIC Stamp may talk
to the LCD too early, the LCD will then miss some of the commands and
the display will operate strangely, or not at all.
Do not change the "wake-up" and "4-bit mode" sequence commands.
However, the commands below the line that says, "Set data bus to 4-bit
mode" may be modified to set other desired modes.
Table 5.27 shows the most commonly used LCD commands. Here's an
example:
LCDCMD 1, 16
This will make the LCD's cursor move left by one character (16 is the
Cursor Left command), even if the cursor is not visible. The next character
printed on the display (with the LCDOUT command) will appear at the
current cursor's location. Here's another example:
LCDCMD 1, 128 + 64
The above command will move the cursor to the first character position on
the second line (on a 2 x 16 display). 128 is the Move To Display Address
'LCD's usually take more than 500 µs to power-up. This pause is
'to keep the BASIC Stamp from talking to the LCD too early.
'Send wakeup sequence to LCD (three Wake-Up (48) commands)
'This pause is necessary to meet the LCD specs
'This pause is necessary to meet the LCD specs
'This pause is necessary to meet the LCD specs
'Set data bus to 4-bit mode
'Set to 2-line mode with 5x8 font
'Turn display off
'Turn display on without cursor
'Set to auto-increment cursor (no display shift)
'Clear the display
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 161
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?