;20m2 raining
;c.0
;c.1 adc sensor
;c.2
;c.3 total reset
;c.4
;c.5
;c.6 out to sounder
;c.7 out to display
;B.0 - B.7 Leds
symbol actual=W3
symbol target=W4
symbol diff=w5
symbol reading=W6
symbol auxWord=W7
let diff=50
start:
low 7,6,5,4,3,2,1,0 ;Leds on
pause 2000
readadc10 c.1,actual
target=actual-diff
low c.7
pause 500
serout c.7,N2400,(254,1)
pause 30
high 7,6,5,4,3,2,1,0 ;Leds off
main:
if pin3=1 then goto start
readadc10 c.1,actual
auxword=target+diff
if actual > auxword then let target = actual-diff:endif
reading= w3-w4:
if reading >85 then let reading = 0:endif
gosub leds
SEROUT C.7,N2400,(254,128,"actual ",#w3," ")
serout c.7,n2400,(254,192,"target ",#w4," ")
serout c.7,n2400,(254,148," diff ",#w6," ")
if w3<W4 then tune C.5, 3, %0000000,($40,$05,$49,$05,$40,$2B,$C7,$45,$04,$47,$04,$64,$29,$C5,$40,$05,$49,$05,$40,$2B,$C7,$45,$04,$40,$02,$44,$85,$40,$42,$44,$45,$8C,$42,$44,$45,$47,$8C,$42,$44,$45,$47,$0C,$42,$44,$45,$47,$0C,$00,$44,$85):endif
;tune c.5, 1, %00000000,($1)
serout c.7,N2400,(254,147,"R")
SEROUT c.7,N2400,(254,212," ")
IF W3<W4 THEN SEROUT c.7,N2400,(254,212,"--WARNING RAINING--"):ENDIF
serout c.7,N2400,(254,147," ")
goto main
leds:
if reading>45 then low 7 high 6,5,4,3,2,1,0:goto ledsend:endif
if reading>40 then low 6 high 7,5,4,3,2,1,0:goto ledsend:endif
if reading>35 then low 5 high 7,6,4,3,2,1,0:goto ledsend:endif
if reading>30 then low 4 high 7,6,5,3,2,1,0:goto ledsend:endif
if reading>25 then low 3 high 7,6,5,4,2,1,0:goto ledsend:endif
if reading>15 then low 2 high 7,5,5,4,3,1,0:goto ledsend:endif
if reading>5then low 1 high 7,6,5,4,3,2,0:goto ledsend:endif
low 0 high 7,6,5,4,3,2,1
ledsend:
return