NOTE: This is written for the BS2p and will also run on the BS2pe and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2pe or BS2px.
' LCDCMD.BSP ' This program demonstrates initialization and printing on a 2 x 16 ' character LCD display. The set of "LCD constants", below, are provided ' as pre-defined and useful LCD commands, though not all are actually ' used in this program. ' {$STAMP BS2p} ' {$PBASIC 2.5} #IF ($STAMP < BS2P) #THEN #ERROR "Program requires BS2p, BS2pe, or BS2px." #ENDIF Lcd PIN 0 LcdCls CON $01 ' clear the LCD LcdHome CON $02 ' move cursor home LcdCrsrL CON $10 ' move cursor left LcdCrsrR CON $14 ' move cursor right LcdDispL CON $18 ' shift chars left LcdDispR CON $1C ' shift chars right LcdDDRam CON $80 ' Display Data RAM LcdCGRam CON $40 ' Character Generator RAM LcdLine1 CON $80 ' DDRAM address of line 1 LcdLine2 CON $C0 ' DDRAM address of line 2 Init_LCD: PAUSE 1000 ' allow LCD to self-initialize first LCDCMD Lcd, %00110000 ' send wakeup sequence to LCD PAUSE 5 ' pause required by LCD specs LCDCMD Lcd, %00110000 PAUSE 0 ' pause required by LCD specs LCDCMD Lcd, %00110000 PAUSE 0 ' pause required by LCD specs LCDCMD Lcd, %00100000 ' set data bus to 4-bit mode LCDCMD Lcd, %00101000 ' set to 2-line mode with 5x8 font LCDCMD Lcd, %00001100 ' display on without cursor LCDCMD Lcd, %00000110 ' auto-increment cursor Main: DO LCDOUT Lcd, LcdCls, ["Hello, World!"] LCDOUT Lcd, LcdLine2, ["How are you?"] PAUSE 3000 LCDCMD Lcd, LcdCls PAUSE 500 LOOP END
BASIC Stamp Help Version 2.5.4
Copyright © Parallax Inc.
8/8/2012