Touch Sensor for Arduino

Update: The QT118h is now impossible to find. Apparently the QT product line is extinct. If you are looking for an alternative to the QT118 check out Azoteq’s products

Electronics are no good unless you have a way to interact with them. Typically a standard push button has been the standard. I sell TV’s and LCD monitors for a living and all of the new models have removed all the boring buttons and replaced them with super sexy touch sensors. I wanted to emulate this on my word clock, so that touching a corner will either change the brightness or the hour/minute.

There is a really basic method for detecting touch on an Arduino or similar using just a resistor and a wire however I found it somewhat unreliable. Atmel has a product line called the QTouch, that is specifically designed to do the heavy lifting. I used this one (118H) because it was pretty much the only one I could find in stock. But rest assured, all of the QT line are pretty much the same. The difference between the 188 and the 118h is that the 118h goes from 0v (low) to 5v (high) on the output while the vanilla 188 is the opposite.


Wiring the QT118h:
Here is the IC. The top left pin with the dot is pin 1, and the top right is pin 8. Pins 1,3 and 4 go to positive 5v. Pin 8 goes to ground. Pin 7 connects to whatever you are using as a sensor. It could be a piece of aluminum foil, a nail, or anything else metailic. The beauty of these sensors is that if you turn up the sensitivity, just getting close will indicate a touch. Just imagine hiding your sensor behind a piece of plastic or glass. Pins 5 and 6 each are connected to 1 side of your capacitor. Play around with different values for different sensitivity. 10 nf to 500 nf is the recommended value, but I found 600 nf to be the most accurate for my purpose. The output pin is pin 2. With the 118h, it goes high on a successful touch. Connect it to a LED, a transistor, or an input pin on an arduino like I did.


If you are keeping track, there is still one pin unaccounted for. Pin 5 (bottom right) is for sensitivty, in my situation I left it unhooked for the default maximum gain. wpid-wpid-screen-shot-2010-05-30-at-1-10-30-pm-2010-05-29-18-01-2010-05-29-18-01.png


The QT IC has only two output states, just like a pushbutton. You can use the same code with only a change to the input pin. Open up the arduino software, and go to File, Examples, Digital Button.


// constants won’t change. They’re used here to
// set pin numbers:
const int buttonPin = 7; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
else {
// turn LED off:
digitalWrite(ledPin, LOW);


About spuder
spuder is a "super computer" support engineer by day, and tinkerer / hobbyist by night.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: