' GENERATE 16 BIT RANDOM NUMBERS AND FORMAT FOR HD44100 LCD DISPLAY ' 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 'ALL variables used ' initialize display - 4 bit mode with high nibble=data ' standard plus display on, cursor off dirs = %11111100 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 loop: random w5 'get a number w2 = w5 'save w4 = 10000 'initialize conversion 'clear display b0=0: gosub send : b0=16 : gosub send b1=32: for b3 = 0 to 4: gosub cho: next 'center digits 'convert w2 to ascii for b3 = 1 to 5 b2 = w2/w4 lookup b2,("0123456789"),b1 : gosub cho w3 = b2*w4 w2 = w2 - w3 ' remainder w4 = w4/10 ' next digit next pause 500 ' wait a bit goto loop end 'send high nibble of b0 to port, pulse e send: pins = b0|8 : low 3 : return 'send character in b1 to display, first top nibble then bottom cho: b0=b1&240+4 : gosub send b0=16*b1&240+4 : gosub send return