The Capacitive Sensor library example demonstrates how to use the Capacitive Sensor library in practice.
The example initializes the Capacitive Sensor library to constantly monitor the level of the analog input 7 (AIN7). Every time the pad connected to AIN7 is touched, the application will print out information on UART. Additionally, the capacitive slider is enabled. You must connect AIN1, AIN2, and AIN4 to appropriate pads of your self-designed capacitive slider to get it to print out its value.
To run this example, you will need some kind of capacitive pad and slider. These can be made, for example, of aluminum foil. However, to get accurate values from the slider, it should be made of a material that does not change its capacity easily and should be designed according to common rules of capacitive sensor design.
You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\csense
Test the Capacitive Sensor library example application by performing the following steps:
If no information is printed out on UART or the values from the slider are meaningless, try changing the THRESHOLD_VALUE_PAD1 value and the THRESHOLD_VALUE_PAD2 value in the main example file. If the LEDs are not reacting to touch, you must decrease these values, and if the LEDs are already lit up, you need to increase them.
Remember that the slider needs a while to calibrate. The best way to do this is to gently slide through all pads on the slider.