Touch switch ON/OFF


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Touch switch ON/OFF

    OK, I'll answer myself. I got it working. I needed a simple ON/OFF touch switch for controlling solder fumes extractor fan.
    The code is minimalist, because PIC10F222, but working on other PIC as well. Tested on12F683, 12F1840.
    One touch switch ON output, second switch OFF output.
    Here the code:
    Code:
    ; PIC10F222
    #CONFIG  
    cfg = _IOFSCS_8MHZ
    cfg&= _MCPU_OFF                 
    cfg&= _WDT_OFF                                     
    cfg&= _MCLRE_OFF
    cfg&= _CP_OFF
     __CONFIG cfg
    #ENDCONFIG
    
    OPTION_REG.5=0
    ADCON0 = 0 
    TRISIO =%0100
    
    
    LED        VAR GPIO.0
    Generator  var GPIO.1
    
    Sensor     var byte
    
    LED = 0
    Generator = 0
        
                
    Start:
    repeat
    Generator = 1       ' enable sensor power
    Sensor = GPIO      ' read sensor
    Generator = 0       ' disable sensor power
    Sensor = Sensor & 4 ' keep only Sensor bits       
    until Sensor != 1  ' redo the test untill one sensor is touch
        
    if sensor = 0 then toggle LED : pause 500
    
    goto Start

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,656


    Did you find this post helpful? Yes | No

    Default Re: Touch switch ON/OFF

    so what was wrong with the first draft ?
    Warning I'm not a teacher

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Touch switch ON/OFF

    Possibly stupid question but why not have one touch switch, first press turns on, next turns off ... ad nauseam.
    George

Similar Threads

  1. Replies: 0
    Last Post: - 26th January 2015, 05:18
  2. Toggle switch (latching switch) state
    By craigwb in forum General
    Replies: 4
    Last Post: - 6th November 2011, 14:18
  3. Replies: 6
    Last Post: - 9th January 2011, 15:26
  4. Touch Sensitive Switch
    By BobP in forum General
    Replies: 8
    Last Post: - 23rd August 2007, 22:27
  5. touch switch dimmer
    By helmut in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th August 2007, 11:25

Members who have read this thread : 1

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