BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – LCDCMD
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 251
Note that we could have used 1 for the Pin argument and moved the
LCD's Enable pin (pin 6) to I/O pin 1. Similarly, using 9 for the Pin
argument would have required us to wire the LCD's pins to I/O pins 9
through 15, rather than I/O pins 0 and 2 through 7.
When the LCD is first powered-up, it defaults to an 8-bit interface and
must be configured for a 4-bit buss before sending commands like the one
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.
Init_LCD:
PAUSE 1000 ' allow LCD to self-initialize first
LCDCMD 0, %00110000 ' send wakeup sequence to LCD
PAUSE 5 ' pause required by LCD specs
LCDCMD 0, %00110000
PAUSE 0 ' pause required by LCD specs
LCDCMD 0, %00110000
PAUSE 0 ' pause required by LCD specs
LCDCMD 0, %00100000 ' set data bus to 4-bit mode
LCDCMD 0, %00101000 ' set to 2-line mode with 5x8 font
LCDCMD 0, %00001100 ' display on without cursor
LCDCMD 0, %00000110 ' auto-increment cursor
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.44 shows the most commonly used LCD commands. Here's an
example:
LCDCMD 0, 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
INITIALIZING THE LCD; THE MOST
IMPORTANT STE
P
!
C
OMMON LCD COMMANDS.