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 #135 background imageLoading...
Page #135 background image
# 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: time , board and analo
gio . All three modules are built into CircuitPython, so you don't need to download
anything to get started.
©Adafruit Industries Page 135 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
BrandAdafruit
ModelESP32-S3
CategoryMicrocontrollers
LanguageEnglish

Related product manuals