'TONE DETECT PROGRAM FOR BASIC STAMP/HD44100 LCD DISPLAY/RS-232 OUTPUT '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. Uses SI202 tone decoder chip. 'Written by Bob Blick with some LCD code thanks to Jim Remington. 'Bob Blick 1996 'Released into the public domain. No warranties expressed or implied. 'Bob Blick February 18, 2002 'Please see accompanying schematic "tonesch.gif" 'CONNECTIONS 'lcd pin 14 13 12 11 6 4 5 2 1 'port pin on stamp 7 6 5 4 3 2 1 0 gnd +5 gnd 'function db7 db6 db5 db4 e rs DV rs232 r/w vcc gnd 'LCD pin numbers correspond to TIMELINE 16x1 LCD display. 'Change LCD pin numbers to suit your display. 'e=enable rs=reset 'DV is data valid output of tone decoder chip 'Stamp supplies 5 volts to LCD, tone decoder, preamplifier. 'variables used: b0=command byte, b1=data byte, b2 = temp dirs = %11111101 '7 output, 1 input bits gosub init 'initialize display - 4 bit mode with high nibble=data 'send hello string to display for b2 = 0 to 15 lookup b2,(" Bob Blick "),b1 gosub lcdout next for b2 = 0 to 1 lookup b2,(0,112),b0 'scroll mode selected gosub send next 'main loop, no check for line length. Plenty space for such options! loop: dirs = %00001101 'prepare for decoded tone test1: if pin1 = 0 then test1 'do we have a tone? b1 = pins 'got one b1 = b1/16 'convert to ascii lookup b1,(68,49,50,51,52,53,54,55,56,57,48,42,35,65,66,67),b1 dirs = %11111101 'prepare for output gosub lcdout 'send it to LCD serout 0,4,(b1) 'serial port gets it too test2: if pin1 = 1 then test2 'same tone? goto loop 'ready for new tone '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 lcdout: '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