Capacitive touch sensing alarm clock

This is a side project I worked on recently as a present for a special person. It has some new cool features that I thought is worthy of a mention here. What’s different about this clock is that it uses capacitive touch sensing to display and adjust the alarm and time.

Here’s a video of the clock I made that explains how to use it (The time is a bit difficult to see in the video because of the glare)

Capacitive touch sensing is a technology that detects the change in capacitance as a result of the presence of a human finger. Nowadays this technology is used everywhere from phones to elevator keypads to pedestrian crossing activators in the streets. A capacitor is formed when two conductors are separated by an insulator or dielectric material. The typical capacitance created by a human finger is in the order of ~100 pF (according to the human body model as defined by the Electrostatic Discharge Association).

Capacitive touch sensing involve detecting a change in capacitance. The capacitance can be measured by measuring the time it takes for a capacitor to discharge across a known resistance. The capacitive sensing element I used in my clock is shown in the schematic below.

The basic capacitive touch sensing element consists of a capacitor and a resistor in parallel

The sensing element is simply a capacitor and a resistor in parallel. I used a 22 pF capacitor because it is smaller than a typical capacitance created by a human finger (~100 pF). I chose a 1 Mohm resistor to increase the capacitor discharge time so it can be conveniently measured by the ADC.

The capacitive elements must be connected to ADC pins (analog pins) of the microcontroller if using the ADC to measure the voltage across the capacitors, which is what I used in my project.

Sensing the human finger

To sense the capacitance, first we charge the capacitor by driving the pin High. Then we configure the pin to be an input. When the pin is configured as an input, the capacitor begins to discharge across the 1 Mohm resistor. After a set period of time, we measure the voltage at the input pin using the ADC. This voltage value will depend on the capacitance at the sensing element. If a human finger is present, it increases the capacitance and therefore the time it takes for the capacitor to discharge to a given voltage. So the ADC will read a higher than normal voltage if a human finger is present.

The following shows a basic flowchart of the process for capacitive touch sensing I used in my project.


Flow chart for capacitive touch sensing

The four capacitive touch sensing pins can be checked sequentially following the same process shown in the above flow chart.

Below is code snippet that implements capacitive touch sensing in Arduino:

// set capPin as output and drive high
DDRC |= (1 << capPin);
PORTC |= (1 << capPin);
//set capPin as input and turn off pull-up resistor
DDRC &= ~(1 << capPin);
PORTC &= ~(1 << capPin);
// turn on ADC and enable interrupt
ADCSRA = (1 << ADEN) | (1 << ADIE);
// select capPin as input channel to ADC and AVCC as voltage reference
ADMUX = capPin | (1 << REFS0);
// delay before reading pin value
// start a conversion
ADCSRA |= (1 << ADSC);


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close