E CON 0 ' LCD Enable pin (1 = enabled) RS CON 3 ' Register Select (1 = char) LCDout VAR OutH ' 8-bit LCD data ClrLCD CON $01 ' clear the LCD CrsrHm CON $02 ' move cursor to home position CrsrLf CON $10 ' move cursor left CrsrRt CON $14 ' move cursor right DispLf CON $18 ' shift displayed chars left DispRt CON $1C ' shift displayed chars right DDRam CON $80 ' Display Data RAM control char VAR Byte ' character sent to LCD index VAR Byte ' loop counter ' ------------------------------------------------------------------------- Msg DATA "THE BASIC STAMP!",0 ' preload EEPROM with message ' ------------------------------------------------------------------------- Initialize: DirL = %11111111 ' setup pins for LCD DirH = %11111111 GOSUB LCDinit ' initialize LCD for 8-bit mode ' ------------------------------------------------------------------------- Main: char = ClrLCD ' clear the LCD GOSUB LCDcommand PAUSE 500 index = Msg ' get EE address of message ReadChar: READ index,char ' get character from EEPROM IF char = 0 THEN MsgDone ' if 0, message is complete GOSUB LCDwrite ' write the character index = index + 1 ' point to next character GOTO ReadChar ' go get it MsgDone: ' the message is complete PAUSE 2000 ' wait 2 seconds char = CrsrHm ' move the cursor home GOSUB LCDcommand char = %00001110 ' turn the cursor on GOSUB LCDcommand PAUSE 500 char = CrsrRt FOR index = 1 TO 15 ' move the cursor accross display GOSUB LCDcommand PAUSE 150 NEXT FOR index = 14 TO 0 ' go backward by moving cursor char = DDRam + index ' to a specific address GOSUB LCDcommand PAUSE 150 NEXT char = %00001101 ' cursor off, blink on GOSUB LCDcommand PAUSE 2000 char = %00001100 ' blink off GOSUB LCDcommand FOR index = 1 TO 10 ' flash display char = char ^ %00000100 ' toggle display bit GOSUB LCDcommand PAUSE 250 NEXT PAUSE 1000 GOTO Main ' do it all over END ' ------------------------------------------------------------------------- LCDinit: PAUSE 500 ' let the LCD settle LCDout = %0011 ' 8-bit mode PULSOUT E,1 PAUSE 5 PULSOUT E,1 PULSOUT E,1 char = %00001100 ' disp on, crsr off, blink off GOSUB LCDcommand char = %00000110 ' inc crsr, no disp shift GOSUB LCDcommand RETURN LCDcommand: LOW RS ' enter command mode LCDwrite: LCDout = char ' output high nibble PULSOUT E,1 ' strobe the Enable line HIGH RS ' return to character mode RETURN