Shop OBEX P1 Docs P2 Docs Learn Events
just a little help with a lcd display — Parallax Forums

just a little help with a lcd display

propwashpropwash Posts: 20
edited 2006-06-07 02:33 in BASIC Stamp
idea.gif·ts been a long time since i was on this fourm. i have asked for answers in the past and everyone was very helpful. i have built the lightning detector and it worked good for about 8 months till you guess it lightning took it out!! well nothing was damaged only the 9volt was blowen to dust!!i have rebuilt it and it works good so here are 3 or 4 questions i have and i hope anyone can help me??the 1st is what numbers do i have to change to make only 1 color led light up when the lightning activity is around insted of the current program? (what i mean is you have 8 led numbered 1 -8 from left to right as the lightning strikes more per minute the more light up so if you have 10 strike you may have 2leds on and if you have50 strikes you have 5 leds on. i want to change that so if you have 10 strikes· you have 1 led on and if you have 50 strikes the color of the 10 strikes goes out and lites up the led for the 50 strikes.)the 2nd question i have is i have a 4 x 20 lcd display and would like to hook it up and have it read out the number of strike along with the leds?? where would it hook to the basic stamp and could a program be made to fit in and run with the current program(can the basic stamp run 2 programs at the same time? if you have any questions you can e-mail me at propwash79@aol.com and i will have the info for the above below all of this. here is the web site for the lightning detector.Basic Stamp Lightning Activity Monitor·ihope this help some?? here is the program that is for the detector
'
[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·
Sign In or Register to comment.