Let's get blinky going with CircuitPython to explore the way we can write code and confirm everything is working as expected.
After plugging in a board with CircuitPython into your computer a CIRCUITPY drive will appear. At first, the drive may be empty but you can create and edit files on it just like you would on a USB drive. On here, you can save a code.py (code.txt and main.py also work) file to run every time the board resets. This is the CircuitPython equivalent of an Arduino sketch. However, all of the compiling is done on the board itself. All you need to do is edit the file.
So, fire up your favorite text editor, such as Notepad on Windows, TextEdit on Mac or download Atom (my favorite), and create a new file. In the file copy this:
import digitalio import board import time led = digitalio.DigitalInOut(board.D13) led.direction = digitalio.Direction.OUTPUT while True: led.value = not led.value time.sleep(0.5)
Now, save the file to the drive as
code.py also works). After a brief time, the board's red LED should begin to flash every second.
Did the status LED flash a bunch of colors at you? You may have an error in your code. Don't worry it happens to everyone. Python code is checked when you run it rather than before like Arduino does when it compiles. To see the CircuitPython error you'll need to connect to the serial output (like Arduino's serial monitor).
See this guide for detailed instructions.
If you are new to Python try googling the error first, if that doesn't find an answer feel free to drop by the support forum.
Using libraries with CircuitPython is also super easy. Simply drag and drop libraries onto the CIRCUITPY drive or into a
lib folder on the drive to keep it tidy.
Make sure the libraries are for CircuitPython and not MicroPython. There are some differences that may cause it to not work as expected.