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.
' LCDOUT.BSP ' This program demonstrates initialization and printing on a 2x16 ' character LCD display. ' {$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 LCDOUT Lcd, LcdCGRam, ' load custom chracter map [$00, $0A, $0A, $00, $11, $0E, $06, $00] Main: DO LCDOUT Lcd, LcdCls, ["Hello my friend."] PAUSE 750 LCDOUT Lcd, LcdLine2, ["How are you?"] PAUSE 1500 LCDCMD Lcd, LcdCls LCDOUT Lcd, LcdLine1 + 1, ["I'm doing just"] LCDOUT Lcd, LcdLine2 + 4, ["fine! ", 0] PAUSE 2000 LOOP END
BASIC Stamp Help Version 2.5.4
Copyright © Parallax Inc.
8/8/2012