Adafruit ESP32-S3 Manual page 135

Tft feather
Table of Contents

Advertisement

# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""CircuitPython analog pin value example"""
import time
import board
import analogio
analog_pin = analogio.AnalogIn(board.A0)
while True:
print(analog_pin.value)
time.sleep(0.1)
Now, rotate the potentiometer to see the values change.
What do these values mean? In CircuitPython ADC values are put into the range of 16-
bit unsigned values. This means the possible values you'll read from the ADC fall
within the range of 0 to 65535 (or 2^16 - 1). When you twist the potentiometer knob to
be near ground, or as far to the left as possible, you see a value close to zero.
When you twist it to the right, the value gets bigger up to some value that is
dependent on the microcontroller. Many microcontrollers get a value very close to
65535. Some, such as the ESP32-S3, have a smaller limit of about 61000 or 3.1 volts.
The code is simple. You begin by importing three modules:
. All three modules are built into CircuitPython, so you don't need to download
gio
anything to get started.
©Adafruit Industries
,
and
time
board
Page 135 of 263
analo

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Table of Contents

Save PDF