Year on year, microcontrollers and development platforms are shipping with ever-increasing feature sets. In the distant past, if you wanted an analog to digital converter or a PWM driver, you had to tack extra ICs on to your design. Nowadays, it’s all baked in at the factory. Of course, you may still find yourself working with a platform that lacks capacitive touch inputs. That’s no problem, though – you can do it all without dedicated hardware anyway!
Capacitive touch sensing works by creating an RC oscillator, and allowing the user to affect the capacitance in the circuit through touch or proximity. By sensing the changes in the frequency of the oscillator, it’s possible to determine whether the object or pad is being touched or not. As the capacitance changes can be small, sometimes it’s desired to use a high frequency oscillator, and then pass the output through a frequency divider, which allows changes to be measured more easily by a slower microcontroller.
[Gabriel] does a great job of both explaining the theory involved, as well as presenting a practical way to achieve this with basic hardware. If you need to add touch sensitivity to an existing or otherwise limited platform, this is an easy way to go about doing it. There are definitely some interesting things you can do with the technology, after all.
While not /quite/ as sensitive, if you only want to touch through something like a window(few mm), every single AVR based Arduino has a ‘dedicated’ touch sensor built in, in the form of the QTouchADC/QTouchADCArduino library.
Including most of the ATTiny’s :) And has been even ported to some SAM hardware.
It’s fast, adaptive and requires no external hardware short of the touch pad.
Always good to know how to make it better though!
You don’t even need QTouch. You can do it entirely bit-banging. I you can also use a timer and pin change IO for even more multilevel precision/goodness :) https://www.youtube.com/watch?v=kWCsBwKYi9E
Good trick to know. One of the first (if not the very first) videos I uploaded on my yt channel was implementing this same idea on a pic16f84a reading two touch inputs to light up two leds! Those were the days … everything was fresh and new, seemingly filled with magic. Now I’m just a pessimistic engineer …
A “few” years ago Mims had some variations on this theme in his notebooks.
It’s far more sensitive than you think, he shows how it can sense his hand trough 3.5cm of wood in the video