Skip to main content
Topic: Single pin capacitive touch sensing with an AVR (Read 2717 times) previous topic - next topic

Single pin capacitive touch sensing with an AVR

Hi there.

I've had a project idea on my mind for a while now that would probably need some capacitive touch buttons, but I've never used them before. About a month ago I started looking at some of the possibilities out there. After ruling out external controllers as an option, I noticed that Atmel provides a library for using a normal AVR ADC peripheral to do capacitive touch sensing, with only a single external component. The library is provided as a binary blob, however, and I couldn't find any source code for it. So I decided to try implementing it myself.

As far as I could figure it out, the idea is to take advantage of the sample&hold capacitor inside the ADC block.

I ended up making a dedicated PCB with an ATMega32u4 microcontroller for testing out the capacitive touch sensing (it's amazing having access to a PCB router at the university, transforming a PCB design into a physical board is simply a matter of some clicks of a mouse and waiting 30 minutes. Except for vias, they need to be painstakingly riveted one at a time...):

I've got a full writeup of the experimentation on my website, including my understanding of the theory of operation and code (and a video of the board in action, the three buttons controlling the three colors of an RGB LED): ... le-adc-pin

I'm sure this has been done before many times over, but I had fun trying to figure it out myself and it seems like a pretty elegant and reliable solution in my opinion. I'll probably end up using this in a project in the near future.

Thoughts, comments and corrections are always welcome.


Re: Single pin capacitive touch sensing with an AVR

Reply #1
Very cool, thanks for sharing and liberating the technique from the binary blob :)

I've heard before that most methods of cap sense touching are covered by patents, that may be why everyone is so fussy about it.
Got a question? Please ask in the forum for the fastest answers.