What if I Don't Have the Loop?
If you don't have the loop, the code will run to the end and exit. This can lead to some
unexpected behavior in simple programs like this since the "exit" also resets the state
of the hardware. This is a different behavior than running commands via REPL. So if
you are writing a simple program that doesn't seem to work, you may need to add a
loop to the end so the program doesn't exit.
The simplest loop would be:
while True:
pass
And remember - you can press CTRL+C to exit the loop.
See also the
Behavior section in the
Connecting to the Serial Console
One of the staples of CircuitPython (and programming in general!) is something called
a "print statement". This is a line you include in your code that causes your code to
output text. A print statement in CircuitPython (and Python) looks like this:
print("Hello, world!")
This line in your code.py would result in:
Hello, world!
However, these print statements need somewhere to display. That's where the serial
console comes in!
The serial console receives output from your CircuitPython board sent over USB and
displays it so you can see it. This is necessary when you've included a print statement
in your code and you'd like to see what you printed. It is also helpful for
troubleshooting errors, because your board will send errors and the serial console will
display those too.
The serial console requires an editor that has a built in terminal, or a separate
©Adafruit Industries
docs ().
Page 51 of 263
Need help?
Do you have a question about the ESP32-S3 and is the answer not in the manual?