EasyManua.ls Logo

Parallax BASIC Stamp 2e - Page 163

Default Icon
353 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
5: BASIC Stamp Command Reference LCDCMD
BASIC Stamp Programming Manual 2.0c www.parallaxinc.com Page 161
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: 'LCD's usually take more than 500
µs to power-up. This pause is
PAUSE 1000 'to keep the BASIC Stamp from talking to the LCD too early.
LCDCMD 1, 48 'Send wakeup sequence to LCD (three Wake-Up (48) commands)
PAUSE 10 'This pause is necessary to meet the LCD specs
LCDCMD 1, 48
PAUSE 1 'This pause is necessary to meet the LCD specs
LCDCMD 1, 48
PAUSE 1 'This pause is necessary to meet the LCD specs
LCDCMD 1, 32 'Set data bus to 4-bit mode
LCDCMD 1, 40 'Set to 2-line mode with 5x8 font
LCDCMD 1, 8 'Turn display off
LCDCMD 1, 12 'Turn display on without cursor
LCDCMD 1, 6 'Set to auto-increment cursor (no display shift)
LCDCMD 1, 1 'Clear the display
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
COMMON LCD COMMANDS.

Table of Contents

Related product manuals