Hi ! After a long time I re-started to use my solder station ...and I tried to build a simple switch.
I need to read the ADC on 12F675 and doing two actions, one if the time is less than 2 sec, the second if time is bigger than 2 sec.
I searched through forum but I haven't find a clue ...
Can someone point me the right direction ?
Thanks in advance !
Code:
@ __config _XT_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _BODEN_ON & _CP_ON
DEFINE OSC 4
CMCON = 7
TRISIO = %00001001
INTCON = 0
IOC = 0
GPIO = 0
ANSEL = %00110001
DataW var word
GPIO.1 = 0
GPIO.2 = 0
ADCON0 = %10000001
Pauseus 50 ' Wait for channel to setup
;============================================================================
Main:
ADCON0.1 = 1 ' Start conversion
While ADCON0.1=1:Wend ' Wait for conversion
DataW.HighByte=ADRESH ' Read variable from ADC and save
DataW.LowByte=ADRESL
IF DataW < 1020 then
if time =< 2 sec then GPIO.1 = 1 ; how to count if DataW < 1020 for less than 2 sec ?
if time > 2 sec then GPIO.2 = 1 ; how to count if DataW < 1020 for more than 2 sec ?
ENDIF
Return
Bookmarks