I have a code I found on the internet that is a simple hot/cold detector with 2 led's. Well the problem is if a new ambient temperature is introduced it will just stay on the color of the ambient temperature unless I turn the unit off and back on again to reset the unit. Well I have found an electrical work-around using a 555 timer to reset the circuit every 30 seconds which is what I desire. However I am getting tired of building the 555's every time I build them so I know someone out there can write a simple code to do this for me automatically through the pic chip12... I have contacted the original owner of the code and he said he doesn't have the time to even look at it, so Im hoping someone here can help me. It would be greatly appreciated! Basically I need the chip to turn off then back on every 30 seconds as if I would do it with the on/off switch manually.
Here is a sample of the code im using.
Code:
@ Device PIC12F675,PROTECT_OFF,INTRC_OSC_NOCLKOUT,MCLR_OFF
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
' Requires Pic Basic Pro to compile for the Microchip 12F675.
CMCON=7
GPIO=%00000000
TRISIO=%010110
ANSEL=%00111110
ADCON0=%11001100
t VAR WORD
c VAR WORD
cl VAR WORD
m VAR BYTE
hh VAR BYTE
ch VAR BYTE
u VAR BYTE
d VAR BYTE
u=0
d=0
hh=2
ch=1
cl=0
pause 250
ADCIN 3, t
ADCIN 2, c
if(t>c) then
cl=t-c
m=1
endif
if(t<c) then
cl=c-t
m=0
endif
loop:
ADCIN 3, t
ADCIN 2, c
if m=1 then
t=t-cl
else
t=t+cl
endif
if u>10 then
GPIO.0=0
GPIO.5=1
endif
if d>10 then
GPIO.5=0
GPIO.0=1
endif
if t>(c+ch) then
u=u+1
d=0
goto loop
else
if t<(c-hh) then
d=d+1
u=0
goto loop
endif
endif
u=0
d=0
GPIO.0=0
GPIO.5=0
nap 2
GoTo loop
Bookmarks