This is the firmware repo for the Core Electronics PiicoDev® Capacitive Touch Sensor CAP1203
This module depends on the PiicoDev Unified Library, include PiicoDev_Unified.py in the project directory on your MicroPython device.
main.py is a simple example to get started.
# PiicoDev Capacitive Touch Sensor CAP1203 demo code
# Read the touch sensor buttons and print the result
from PiicoDev_CAP1203 import PiicoDev_CAP1203
from PiicoDev_Unified import sleep_ms # cross-platform-compatible sleep
touchSensor = PiicoDev_CAP1203()
while True:
# Example: Display touch-pad statuses
status = touchSensor.read()
print("Touch Pad Status: " + str(status[1]) + " " + str(status[2]) + " " + str(status[3]))
sleep_ms(100)| Parameter | Type | Range | Default | Description |
|---|---|---|---|---|
| bus | int | 0,1 | Raspberry Pi Pico: 0, Raspberry Pi: 1 | I2C Bus. Ignored on Micro:bit |
| freq | int | 100-1000000 | Device dependent | I2C Bus frequency (Hz). Ignored on Raspberry Pi |
| sda | Pin | Device Dependent | Device Dependent | I2C SDA Pin. Implemented on Raspberry Pi Pico only |
| scl | Pin | Device Dependent | Device Dependent | I2C SCL Pin. Implemented on Raspberry Pi Pico only |
| addr | int | 0x28 | 0x28 | This address cannot be changed |
| touchmode | string | 'single' / 'multi' | 'multi' | 'single': allow only one touch pad to operate at one time. 'multi': allow multiple touches at the same time |
| sensitivity | int | 0 - 7 | 0: Highest Sensitivity, 7: Minimum Sensitivity | Selects the sensitivity of the touch sensor. |
Returns a dictionary with the status of each touch pad.
| Parameter | Type | Description |
|---|---|---|
| 1 | int | Touch pad 1 reading |
| 2 | int | Touch pad 2 reading |
| 3 | int | Touch pad 3 reading |
Returns a dictionary with the raw reading of each touch pad.
| Parameter | Type | Description |
|---|---|---|
| 1 | int | Touch pad 1 reading |
| 2 | int | Touch pad 2 reading |
| 3 | int | Touch pad 3 reading |
This project is open source - please review the LICENSE.md file for further licensing information.
If you have any technical questions, or concerns about licensing, please contact technical support on the Core Electronics forums.
"PiicoDev" and the PiicoDev logo are trademarks of Core Electronics Pty Ltd.