Hi !
I need again for your help ! I tried to build one simple schematic ; I used 12F675 for reading ADC. Works fine.
But ... I have no clue how to "find" if the button is pressed short (let's say under 1 sec) or long ( > 1 sec) ...for having different commands.
Can someone point me into the right direction ?
Thanks in advance ! Have a nice day and weekend !
Code:
@ __config _XT_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _BODEN_ON
DEFINE OSC 4
CMCON = 7
TRISIO = %00001001
INTCON = 0
IOC = 0
GPIO = 0
ANSEL = %00110001
ADCON0.7 = 1
DataW var WORD ' Just a WORD Temporary working variable
Main:
ADCON0 = %10000001
Pauseus 50 ' Wait for channel to setup
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 > 0 AND DataW < 1023 then GPIO.2 = 1
Pause 1000
GPIO.2 = 0
Goto Main
Bookmarks