nRF5 SDK v12.1.0
Capacitive Sensor Library Example

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

Testing

Test the Capacitive Sensor library example application by performing the following steps:

  1. Compile and program the application.
  2. Connect the prepared pads to analog inputs AIN1 and AIN7.
  3. Start a terminal emulator (for example, PuTTY) and connect to the used COM port with the following UART settings:
  1. After reset, basic information about the example is displayed on UART.
  2. The Capacitive Sensor library now monitors capacitance values of the pads.
  3. If the slider or the button is touched, simple data is printed out on UART.

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.


Documentation feedback | Developer Zone | Subscribe | Updated