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 #50 background imageLoading...
Page #50 background image
Inside our loop, you have four items:
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)
First, you have led.value = True . This line tells the LED to turn on. On the next
line, you have time.sleep(0.5) . This line is telling CircuitPython to pause running
code for 0.5 seconds. Since this is between turning the led on and off, the led will be
on for 0.5 seconds.
The next two lines are similar. led.value = False tells the LED to turn off, and tim
e.sleep(0.5) tells CircuitPython to pause for another 0.5 seconds. This occurs
between turning the led off and back on so the LED will be off for 0.5 seconds too.
Then the loop will begin again, and continue to do so as long as the code is running!
So, when you changed the first 0.5 to 0.1 , you decreased the amount of time that
the code leaves the LED on. So it blinks on really quickly before turning off!
Great job! You've edited code in a CircuitPython program!
What Happens When My Code Finishes Running?
When your code finishes running, CircuitPython resets your microcontroller board to
prepare it for the next run of code. That means any set up you did earlier no longer
applies, and the pin states are reset.
For example, try reducing the code snippet above by eliminating the loop entirely,
and replacing it with led.value = True . The LED will flash almost too quickly to
see, and turn off. This is because the code finishes running and resets the pin state,
and the LED is no longer receiving a signal.
To that end, most CircuitPython programs involve some kind of loop, infinite or
otherwise.
©Adafruit Industries Page 50 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