If I understand your desired function correctly, maybe this idea?
counter var byte ' a counter for the alarm condition
mainloop:
gosub getA ' get the range value
'display the bargraph and value here
if a<15 then
counter=counter+1 'if range is low increment counter
else
counter=0 'otherwise reset the counter
endif
if counter>150 then
high led 'if the counter has exceeded 150 the turn the alarm on
else
low led ' turn the alarm off
endif
pause 100 ' wait 1/10 sec
goto mainloop ' do it again
you might have to add a little code to prevent counter from rolling over to 0, depending on your application.
This should force the alarm on after 15 continuous seconds of low range condition., and turn the alarm off immediately that the range exceeds 15
Bookmarks