Touch sensor

This is a simple circuit which can detect when you touch a sensor connected to one of the sensor inputs. It can be used to add a touch switch to your computer for example. It uses an AVR micro controller, the AT90S2313. This is overkill. I can add a lot more sensors than the two sensors I have now, but I had a 2313 to spare and I didn't need more than two sensor :). Anyway, the basic idea is really simple. Make one pin output and another input. Connect a resistor between these pins. The resistor together with the human capacitance (about 100 pF) forms an RC network. The AVR set the output to low and then make a transition from 0V to +5V. 5 µs after this switch, the logic level at the input pin is sampled. If someone is touching the probe connected to the input pin, the capacitor (=human) will not be fully charged, and the input will be a digital 0 and vice versa.

Schematic and board layout

This is the schematic. The potentiometers are there to adjust the sensitivity. 0.5 MOhm is usually a good value.

This is the board layout (made in EAGLE)

Component list:

Name Value Package
R1 4.7 kOhm 1206
R2 1 MOhm
R3 1 MOhm
R4 3.3 kOhm 1206
R5 3.3 kOhm 1206
Q1 BC547 TO-92
Q2 BC547 TO-92
IC1 AT90S2313 DIL20
XC1 8 MHz Murata ceramic resonator
ISP_CON AVR isp connector
SENSOR1 1x2 pin header, sensor 1 connector
SENSOR2 1x2 pin header, sensor 2 connector
SWITCH1 1x2 pin header, output for sensor 1
SWITCH2 1x2 pin header, output for sensor 2
SUPPLY 1x2 pin header, +5V and GND

Almost any NPN transistor will do if you don't have BC547.


The source is written in C and compiled with AVR-GCC.
AVR source code
EAGLE schematic and board layout

Visitors since 22/2 -05: