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
Bookmarks