CircuitPython Touch

There's four capacitive touch pads you can use to detect human touch. They have big pads you can use to attach alligator/croc clips

Whether you use a Circuit Playground Crickit or Feather Crickit, the touch pads are available.

The four capacitive touch pads on the Crickit HAT for Raspberry pi are conveniently on the edge and vave nice holes for clipping alligator clips onto.

You can read the value of the captouch pads from crickit.touch_#.value This will return True (if touched) or False (if not). This is the simplest/easiest way to detect touch, but it has a catch!

We determine if the touch is active by seeing the difference between the current 'raw' reading value and the first value. That means you do need to read the crickit touch pads without touching them first.

Try loading this code and touching the four pads while looking at the REPL

Download: file
import time
from adafruit_crickit import crickit

# Capacitive touch tests

while True:
    if crickit.touch_1.value:
        print("Touched Cap Touch Pad 1")
    if crickit.touch_2.value:
        print("Touched Cap Touch Pad 2")
    if crickit.touch_3.value:
        print("Touched Cap Touch Pad 3")
    if crickit.touch_4.value:
        print("Touched Cap Touch Pad 4")

If you want to get more specific, you can read the 'raw_value' value which is a number between 0 and 1023. Because there's always some capacitance its reading you'll see a starting value of about 250.

You can then test against a threshold, or use it to measure how hard someone is pressing against something (a fingertip vs a palm will give different readings)

Download: file
import time
from adafruit_crickit import crickit

# Capacitive touch graphing test
touches = (crickit.touch_1, crickit.touch_2, crickit.touch_3, crickit.touch_4)

# Open up the serial Plotter in Mu to see the values graphed!

while True:
    touch_raw_values = (crickit.touch_1.raw_value, crickit.touch_2.raw_value,
                        crickit.touch_3.raw_value, crickit.touch_4.raw_value)
    print(touch_raw_values)
    time.sleep(0.1)
This guide was first published on May 16, 2018. It was last updated on May 16, 2018. This page (CircuitPython Touch) was last updated on Nov 15, 2019.