EasyManuals Logo

Adafruit ESP32-S3 User Manual

Adafruit ESP32-S3
263 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #172 background imageLoading...
Page #172 background image
pin is touched.
"""
import time
import board
import touchio
touch = touchio.TouchIn(board.A4)
while True:
if touch.value:
print("Pin touched!")
time.sleep(0.1)
Now touch the pin indicated in the diagram above. You'll see Pin touched! printed
to the serial console!
First you import three modules: time , board and touchio . This makes these
modules available for use in your code. All three are built-in to CircuitPython, so you
don't find any library files in the Project Bundle.
Next, you create the touchio.TouchIn() object, and provide it the pin name using
the board module. You save that to the touch variable.
Inside the loop, you check to see if the pin is touched. If so, you print to the serial
console. Finally, you include a time.sleep() to slow it down a bit so the output is
readable.
That's all there is to reading touch on a single pin using touchio in CircuitPython!
Multiple Capacitive Touch Pins
The next example shows you how to read touches on multiple pins in a single
program.
©Adafruit Industries Page 172 of 263

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Adafruit ESP32-S3 and is the answer not in the manual?

Adafruit ESP32-S3 Specifications

General IconGeneral
Microcontroller/ChipESP32-S3
Clock Speedup to 240 MHz
RAM512 KB
Flash Memory8MB
GPIO Pins45
DAC Channels2
Operating Voltage3.3 V
Input Voltage5 V
I2C2
I2S2
CPUXtensa LX7 dual-core
Wi-Fi802.11 b/g/n
BluetoothBluetooth 5.0

Related product manuals