The touch sensor itself:
almost everything you have on hand and conductive.
The only thing you have to do is to touch the XYZ conductive material and TADA! No mechanical switch or push button... only one floating piece of conductive material.
Maybe not suitable in harsh environement, but working great in home application.
The schematic:
The code:
' Few cents touch sensor ' ====================== ' Using : PIC12F629 ' ' Circuit is quite simple. One pin(GP4) is used as a signal generator. ' This pin send signal to all "virtual push button" (GPIO<2:0>) ' via 3 X 22K resistor. The touch sensor could be almost everything ' conductive. ' ' Once a sensor is touched, the program will blink a LED as follow ' GPIO.0 => 1 Blink ' GPIO.1 => 2 Blink ' GPIO.2 => 3 Blink ' PIC config and programming mode ' =============================== ' @ DEVICE PIC12F629,INTRC_OSC_NOCLKOUT ' internal RC osc @ DEVICE PIC12F629,MCLR_OFF ' Disable external MCLR @ DEVICE PIC12F629,WDT_OFF ' Disable WatchDog timer @ DEVICE PIC12F629,PROTECT_OFF ' Disable device protect @ DEVICE PIC12F629,CPD_OFF ' Disable Code-Protect @ DEVICE PIC12F629,PWRT_ON ' Enable Power-up timer @ DEVICE PIC12F629,BOD_ON ' Enable Brown-out detect ' I/O Alias definition ' ==================== ' LED VAR GPIO.5 Generator var GPIO.4 ' Hardware definition ' =================== ' TRISIO = $0F ' GPIO<3:0> as input ' GPIO<5:4> as output ' CMCON = 7 ' Disable internal comparator ' Variable definition ' =================== ' Sensor var byte Loop var byte ' EEPROM assignement ' ================== ' data @3,3,0,2,1 ' table to convert 'Sensor' variable result to according ' LED blink. See Result list bellow ' Software/hardware initialisation ' ================================ ' led = 0 generator = 0 Start: ' /////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ' / Start \ ' /////////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ' ' Short explanation of the whole thing. ' 1. Send a high level to all sensor input => GPIO<2:0> ' 2. Read GPIO port ' 3. Send a low level to all sensor input ' 4. Keep only GPIO<2:0> bits ' 5. Test result ' ' If no sensor has been touched, the result will be 7 => 0000 0111, case ' else, the body capacitance will introduce sufficient delay between ' step 1 and 2 wich will keep the according bit to 0. ' ' Results will be as follow ' NoSensor => 0000 0111 => 7 ' GPIO.0 => 0000 0110 => 6 ' GPIO.1 => 0000 0101 => 5 ' GPIO.2 => 0000 0011 => 3 ' repeat Generator = 1 ' enable sensor power Sensor = GPIO ' read sensor Generator = 0 ' disable sensor power Sensor = Sensor & 7 ' keep only Sensor bits ' until Sensor != 7 ' redo the test untill one sensor is touch ' ' Now we will flash an LED to confirm wich sensor has been touch ' GPIO.0 => 1 Blink ' GPIO.1 => 2 Blink ' GPIO.2 => 3 Blink ' read sensor,loop ' convert result to blink repeat LED = 1 PAUSE 200 lED = 0 PAUSE 200 loop = loop - 1 until loop = 0 goto start ' do it again...
Re: Voltage regulation circuit 12V to 5V in 5A range
The 2A wall adapter was a quick fix to be able to continue testing.
Demon Today, 00:27The 9V 2A is holding up for now.