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. These files are called
libraries. Some of them are built into CircuitPython. Others are stored on your CIRCUITPY drive in a folder called lib.
The import statements tells the board that you're going to use a particular library in your code. In this example, we
imported three libraries: board , digitalio , and time . All three of these libraries are built into CircuitPython, so no
separate files are needed. That's one of the things that makes this an excellent first example. You don't need any thing
extra to make it work! board gives you access to the
hardware on your board
, digitalio lets you
access that hardware
as inputs/outputs
and time let's you pass time by 'sleeping'
Setting Up The LED
The next two lines setup the code to use the LED.
Your board knows the red LED as D13 . So, we initialise that pin, and we set it to output. We set led to equal the rest
of that information so we 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.
Inside our loop, we have four items: