Long / short press button...but reading ADC


Results 1 to 38 of 38

Threaded View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579

    Default Long / short press button...but reading ADC

    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
    Attached Images Attached Images  

Similar Threads

  1. Replies: 5
    Last Post: - 26th February 2011, 05:51
  2. Button press or not
    By lerameur in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th November 2010, 20:37
  3. 4 Bytes one button press
    By Dennis in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th January 2010, 22:36
  4. Sleep until button press?
    By kevj in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th October 2007, 03:47
  5. Button press and press & hold how to ?
    By GrandPa in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 22nd August 2007, 03:37

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts