Touch Sensor

Capacitive touch breakout boards are an excellent way to use household objects as inputs on your Raspberry Pi. Any conductive object can act as a switch when connected to sensor boards, including potatoes, apples, spoons and pencil graphite.

The capacitive touch sensors detect when you touch the board's pad or an object connected to the board. Humans carry a small electrical charge. When you touch a capacitive touch sensor it will detect this charge.

This is the Schematics corresponding to the Touch Sensor. The GPIO8 Input Pin of the Rasberry Pi Changes its state depending up if the touch crosses threshold or not.

This is the location of the Touch sensor on the board. 

 

This version of the code will continuously print output while the pad is pressed.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import time
import board
from digitalio import DigitalInOut, Direction

pad_pin = board.D23

pad = DigitalInOut(pad_pin)
pad.direction = Direction.INPUT

while True:

if pad.value:
print("pressed")

time.sleep(0.1)