just a little help with a lcd display

'
[noparse][[/noparse] Title ]
'
' File...... bslam.bs2
' Purpose... Basic Stamp Lightning Activity Monitor
' Author.... Tim Bitson
' E-mail.... tbitson@aol.com
' Version... 1.1
' Updated... 05 Jan 2002 - increased values in LOOKDOWN
'
'{$STAMP BS2}
'
'
[noparse][[/noparse] Program Description ]
'
'
' This program displays lightning activity via 8 LEDs connected
' to a BS2 via a SN74LS240N buffer. The lightning is detected by
' I/O port 0 pin 5 and is counted for 6 seconds. Ten 6 second periods
' are summed to calculate the number of lightning strikes per minute (SPM).
' The resulting SPM is compared to a series of threshold values in a LOOKDOWN
' statement to determine the number of LEDs to light. The peak value is also
' stored and the highest reading is displayed on the LEDs on every other loop.
'
'
[noparse][[/noparse] I/O Definitions ]
'device·i/o·port·pin··function
'
'LED 1·<-·8·13··output - green led
'LED 2·<-·9·14··output - green led
'LED 3·<-·10·15··output - yellow led
'LED 4·<-·11·16··output - yellow led
'LED 5·<-·12·17··output - yellow led
'LED 6·<-·13·18··output - yellow led
'LED 7·<-·14·19··output - red led
'LED 8·<-·15·20··output - blue led
'LSU··->·0·5··input - lightning sensor input
'
[noparse][[/noparse] Constants ]
LSU··con·0···' lightning sensor input pin
'
[noparse][[/noparse] Variables ]
counts·var·byte(10)··' measured counts array
sum··var·word···' sum of 10 6-second measurments
index··var·byte···' index value for lookup/lookdown
leds··var·byte···' led output value
oldPeak·var·byte···' peak led value
newPeak·var·byte···' maximum value
showPeak·var·bit···' bit to indicate to show peak
i··var·byte···' loop counter
'
[noparse][[/noparse] Initialization ]
' do an led lamp test to start
DIRS = $FF00····' P0 - P7: Inputs P8 - P15: Outputs
leds = %11111111····' all leds on
FOR i = 0 TO 8····' step thru all 8 leds
·OUTH = leds····' turn on selected leds
·PAUSE 250····' wait a bit
·leds = leds/2···' turn off upper led
NEXT
'
[noparse][[/noparse] Main Code ]
loop:······' main program loop
COUNT LSU, 6000, counts(0) ··' count lightning strikes
DEBUG dec ? counts
sum = 0·····' clear sum
FOR i = 0 TO 9····' add 10 6 second periods
·sum = sum + counts(i)··' sum is total strikes for the last minute
NEXT
DEBUG dec ? sum
'······ index =· 0··· 1··· 2··· 3··· 4··· 5··· 6··· 7··· 8
LOOKDOWN sum,>=[noparse][[/noparse]400, 200, 100,· 50,· 25,· 10,·· 5,·· 1,·· 0], index
LOOKUP index,· [noparse][[/noparse]$FF, $7F, $3F, $1F, $0F, $07, $03, $01, $00], leds
LOOKUP index,· [noparse][[/noparse]$80, $40, $20, $10, $08, $04, $02, $00, $00], newPeak
' check if new peak if greater than old peak
if newPeak <= oldPeak then doLeds
oldPeak = newPeak
goto doLeds
shiftValues:····' loop thru array
FOR i = 8 TO 0
·counts(i+1) = counts(i)··' shift array values to next position
NEXT
showPeak = showPeak + 1···' alternate between 0 and 1
GOTO loop·····' loop for more
'
[noparse][[/noparse] Subroutines ]
doLeds:
if showPeak then doLedsWithPeak
OUTH = leds
GOTO shiftValues
doLedsWithPeak
OUTH = leds· | oldPeak
GOTO shiftValues·