import board
import touchio
touch_one = touchio.TouchIn(board.A4)
touch_two = touchio.TouchIn(board.D12)
while True:
if touch_one.value:
print("Pin one touched!")
if touch_two.value:
print("Pin two touched!")
time.sleep(0.1)
Touch the pins to see the messages printed to the serial console!
This example builds on the first. The imports remain the same.
The
touchio.TouchIn()
second
touchio.TouchIn()
using the
module, and is saved to
board
Inside the loop, we check to see if pin one and pin two are touched, and if so, print to
the serial console
same
time.sleep()
If more touch-capable pins are available on your board, you can easily add them by
expanding on this example!
The Available Touch-Capable Pins
•
A4 - CircuitPython:
•
A5 - CircuitPython:
•
D13 - CircuitPython:
•
D12 - CircuitPython:
•
D11 - CircuitPython:
©Adafruit Industries
object is created, but is instead saved to
object is also created, the second pin is provided to it
Pin one touched!
is included.
. Arduino:
board.A4
. Arduino:
board.A5
. Arduino:
board.D13
. Arduino:
board.D12
. Arduino:
board.D11
.
touch_two
and
Pin two touched!
.
T14
.
T8
.
T13
.
T12
.
T11
. A
touch_one
, respectively. The
Page 174 of 263
Need help?
Do you have a question about the ESP32-S3 and is the answer not in the manual?