'RS 232 RECEIVE ONLY TERMINAL PROGRAM FOR BASIC STAMP/HD44100 LCD DISPLAY 'This simple program was developed for the 16x1 ascii LCD display from 'TIMELINE using the 4 bit interface option, stamp set currently for 2400 'baud. Requires 1 resistor. 'Written by Jim Remington 3/93. Email: jim@uoxray.uoregon.edu 'CONNECTIONS 'lcd pin 14 13 12 11 6 4 5 3 2 1 'port pin on stamp 7 6 5 4 3 2 1 0 gnd gnd +5 gnd 'function db7 db6 db5 db4 e rs ? rs232 r/w vo vcc gnd 'r/w on lcd is grounded, so no read functions (could use pin 1 for this). 'Stamp supplies 2 mA power to display 'variables used: b0=command byte, b1=data byte, b2 = temp dirs = %11111100 '6 output, 2 input bits gosub init 'initialize display - 4 bit mode with high nibble=data 'send hello string to display for b2 = 0 to 13 lookup b2,(" STAMP on it!"),b1 gosub cho next b2=13 'simulate to clear at start of next line 'main loop, no check for line length. Plenty space for such options! loop: serin 0,4,b1 '2400 baud inverted (27 K resistor interface) b1 = b1 & 127 'clear high bit if necc. if b1 = 13 then save ', erase before next line if b1 = 8 then bs 'back space, backup if b1 < 32 then loop 'control char if b2 <> 13 then nc 'don't erase line first b2 = 0 'clear display and flag, last char was b0=0: gosub send : b0=16 : gosub send 'then output last char nc: gosub cho goto loop 'save for next char input (don't clear display immediately) save: b2 = b1 goto loop 'backspace, shift cursor left, blank, shift. bs: b0=16 : gosub send : b0=0 : gosub send: b1=32 : gosub cho 'a blank b0=16 : gosub send : b0=0: gosub send: goto loop 'SUBROUTINES init: 'set 4 bit interface and initialize, standard plus display on, cursor off for b2 = 0 to 13 lookup b2,(48,48,48,32,32,0,0,128,0,16,0,96,0,192),b0 gosub send next return send: 'output command byte b0 to port, pulse e. Note: assumes bit 2 is clear pins = b0|8 : low 3 return cho: 'send character in b1 to display, first top nibble then bottom b0=b1&240+4 : gosub send 'bit 2 = 4 sets data mode b0=16*b1&240+4 : gosub send return