Capacitance Touch Library

The CapTouch library for the Arduino allows you to use large resistors (1M-10M) to create simple capacitance sensors that can be used like buttons or to create more complex sensors like wheels and stroke sensors.  Official documentation of the library can be found here.  While the library works quite well, capacitance sensing is dependent on a number of factors that can make it unpredictable, for example, change in power supply from USB to battery, weather conditions and different people. For more stable solutions I would recommend the MPR121 which does some regular calibrations and has additional circuits to ensure consistency.  That being said, if you want maximum proximity this approach works best, as you can easily add 10M+ resistors to increase sensitivity.

The following influences the distance at which a hand can be detected:

  • Surface area of the touch pad
  • Size of the resistor (1M – 10M works best)
  • In the code below, the number in lines 27-29 will influence the sensitivity of the reading

When you run the code and open the serial monitor you will see three large numbers that will increase when you touch the pad.  For simplicity, this is the amount of capacitance.  If the amount of capacitance gets too high everything will slow to a halt.  Reduce the numbers in lines 27-29 and the capacitance value will fall.  If it holds up really badly, check that everything is connected properly and there is definitely a resistor connected to the pins.

Capacitance sensing, in general, requires that you play around with different resistors and sizes of touch pads depending on what you are trying to achieve.