Yup, that'll work.
As long as it's the only thing the chip will be doing.
But to answer the original question...
> How to use the Elapsed Timer Demo in a PIC12F675 to maintain a on led by 5 days and then goes off
Code:
CLEAR
LED VAR GPIO.0
CMCON = 7
ANSEL = 0
Include "Elapsed.bas"
Gosub ResetTime ' Reset Time to 0d-00:00:00.00
Gosub StartTimer ' Start the Elapsed Timer
HIGH LED ; Start with LED on
Loop:
if DaysChanged then
DaysChanged = 0
if Days = 5 then LOW LED ; Turn off LED
endif
Goto Loop
Or you can add a blinky LED to show that it's still counting...
Code:
CLEAR
LED VAR GPIO.0
StatLED VAR GPIO.1
CMCON = 7
ANSEL = 0
Include "Elapsed.bas"
Gosub ResetTime ' Reset Time to 0d-00:00:00.00
Gosub StartTimer ' Start the Elapsed Timer
HIGH LED ; Start with LED on
Loop:
if DaysChanged then
DaysChanged = 0
if Days = 5 then LOW LED ; Turn off LED
endif
IF SecondsChanged then
SecondsChanged = 0
Toggle StatLED
endif
; Rest of the program goes here
Goto Loop
And you can still do other stuff at the same time.
Bookmarks