Shop OBEX P1 Docs P2 Docs Learn Events
running l.c.d witha bs2?? — Parallax Forums

running l.c.d witha bs2??

propwashpropwash Posts: 20
edited 2006-06-21 23:05 in BASIC Stamp
the question i have is in the basic stamp manual 2.0 book it shows under the l.c.d out section that this is only for the bs2p and no other bs? the reason i ask this is i have a 4x20serial l.c.d by scott edwards and want to have it display a number that the bs2 counts over 6 seconds and display it on the display and if the value is higher than the current number replace the number with that value and the same if its lower all while its doing the same but with l.e.ds??here is the program i have and would it be easy to add the lcd into this program or just erase this program and have the l.c.d only?? thanks for any help.the l.c.d is4x20 scott edwards l.c.d module(bpp-420)v4.0 hope this helps some?? thanks steven···············'
[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··················································

Comments

Sign In or Register to comment.