This example demonstrates implementing CapSense buttons and slider for PSoC 6 MCU with Mbed OS.
This example demonstrates implementing CapSense® buttons and slider for PSoC® 6 MCU with Mbed OS using the CapSense Middleware Library. Additional PSoC 6-related code examples are available in other repos. See all examples at Code Examples for Modus Toolbox.
Instructions to run the CapSense code example
Import the code example
mbed import https://github.com/cypresssemiconductorco/mbed-os-example-capsense
Change working directory to the example folder
Plug in the CY8CPROTO-062-4343W kit. Ensure that the kit has the latest version of KitProg3 firmware and is in DAPLink mode to allow programming from Mbed CLI. See Firmware-loader for more information on how to update the firmware and switch to DAPLink mode.
Ensure the kit is configured to operate at 3.3 V. See the kit user guide to learn how to configure the power supply.
Note: The project works only with VDD = 3.3 V.
Compile the example and Program
mbed compile --target CY8CPROTO_062_4343W --toolchain GCC_ARM --flash --sterm For other targets: mbed compile -m CY8CKIT_062_WIFI_BT -t GCC_ARM -f --sterm mbed compile -m CY8CKIT_062_BLE -t GCC_ARM -f --sterm
Note: The –sterm option opens the serial terminal with 9600-8N1 setting on the command prompt itself after programming completes. Do not use this option if you wish to connect using another serial terminal application.
Following message is displayed on the serial terminal when the application starts running.
Application has started. Touch any CapSense button or slider.
Touch the buttons or the slider to observe the red LED changing its state and the status printed on the serial terminal.
You can also monitor the CapSense data using the CapSense Tuner application as explained below.
How to monitor data using CapSense Tuner
/ModusToolbox_\to run the CapSense Tuner application. /tools/capsense-configurator-\ /capsense-tuner
Click File -> Open and open cycfg_capsense.h file which is available in this example directory.
Switch from DAPLink mode to KitProg mode.
- For single-button kits (CY8CPROTO_062_4343W) press button SW3 (MODE) for more than 2 seconds and release.
- For two-button kits (CY8CKIT_062_BLE and CY8CKIT_062_WIFI_BT) press and release button SW4 (CUSTOM APP).
In the Tuner application, click the settings icon or click Tools -> Tuner Communication Setup. In the window that appears, select I2C under KitProg and configure as follows.
I2C Address: 8 Sub-address: 2-Bytes Speed (kHz): 400
Click the Connect button or Communication -> Connect.
Click the Start button or Communication -> Start.
Under Widget View tab on the right side, you can see the corresponding widgets turning blue when you touch the button or slider. You can also view the sensor data in Graph View tab. e.g. To view sensor data for Button 0, you need to select Button0_Rx0 under Button0.
See the ModusToolbox CapSense Tuner Guide (Help -> View Help) for more information.
- CapSense Middleware API Reference Guide
- CapSense Configurator Guide
- CapSense Tuner Guide
- ModusToolbox IDE User Guide
- CY8CPROTO-062-4343W PSoC 6 Wi-Fi BT Prototyping kit
- CY8CKIT-062-WiFi-BT PSoC 6 WiFi-BT Pioneer Kit
- CY8CKIT-062-BLE PSoC 6 BLE Pioneer Kit
Tested with mbed-os v5.11.4 and CapSense middleware v1.2
Tested with mbed-os v5.13.1 and CapSense middleware v2.0