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 #49 background imageLoading...
Page #49 background image
Imports & Libraries
Each CircuitPython program you run needs to have a lot of information to work. The
reason CircuitPython is so simple to use is that most of that information is stored in
other files and works in the background. The files built into CircuitPython are called m
odules, and the files you load separately are called libraries. Modules are built into
CircuitPython. Libraries are stored on your CIRCUITPY drive in a folder called lib.
import board
import digitalio
import time
The import statements tells the board that you're going to use a particular library or
module in your code. In this example, you imported three modules: board ,
digitalio , and time . All three of these modules are built into CircuitPython, so no
separate library files are needed. That's one of the things that makes this an excellent
first example. You don't need anything extra to make it work!
These three modules each have a purpose. The first one, board , gives you access to
the hardware on your board. The second, digitalio , lets you access that hardware
as inputs/outputs.The third, time , let's you control the flow of your code in multiple
ways, including passing time by 'sleeping'.
Setting Up The LED
The next two lines setup the code to use the LED.
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
Your board knows the red LED as LED . So, you initialise that pin, and you set it to
output. You set led to equal the rest of that information so you don't have to type it
all out again later in our code.
Loop-de-loops
The third section starts with a while statement. while True: essentially means,
"forever do the following:". while True: creates a loop. Code will loop "while" the
condition is "true" (vs. false), and as True is never False, the code will loop forever.
All code that is indented under while True: is "inside" the loop.
©Adafruit Industries Page 49 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