The main editing window when starting is shown above. Directories and files are to the left and the code is to the right. If a terminal is opened, it is shown at the bottom.
VS Code for Education names the main code file main.py. That's fine although if you want to stick to CircuitPython convention, you may right click main.py and rename it code.py.
Working On Your Program
At this point you can edit your program or copy code from other places and paste it into the editor. VS Code is fabulous for syntax highlighting. The editor cannot suggest arguments for module functions, though.
"""CircuitPython Essentials Internal RGB LED red, green, blue example""" import time import board if hasattr(board, "APA102_SCK"): import adafruit_dotstar led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1) print("\nDotStar\n") else: import neopixel led = neopixel.NeoPixel(board.NEOPIXEL, 1) print("\nNeoPixel\n") led.brightness = 0.3 while True: led[0] = (255, 0, 0) time.sleep(0.5) led[0] = (0, 255, 0) time.sleep(0.5) led[0] = (0, 0, 255) time.sleep(0.5)
The editor will save your code to the cloud and Microsoft touts strong security for their infrastructure. Click the "hamburger" icon in the upper left of the screen, select File, then save it wherever you want, cloud or locally.
Running the Code on Your Board
To run your edited code, you can copy the code to the board CIRCUITPY drive. Nearly all CircuitPython boards show up as a "thumb drive" named CIRCUITPY when they are connected with a USB cable to your computer (with notable exceptions ESP32 (original) and ESP32-C Series).
Click the "hamburger" icon then File and Save As, like in saving your work. Click the Show Local button to save on your local computer. A File Explorer/Finder window will come up.
Save on the CIRCUITPY drive as code.py. The file should run immediately.
You might get a popup saying the file could be dangerous. That's likely your browser making sure you trust VS Code. You can click Save.
In the example code I have, for CircuitPython boards with a NeoPixel or DotStar status LED, it will alternate flashing Red, Green, Blue.
Strengths and Limitations of VS Code for Education
VS Code for Education is a trustworthy program with no executable to upload in local environments, making it great for portability and for class environments. But it may not be an ideal editor for CircuitPython.
Strengths
- Trustworthy
- Free
- No downloads
- Syntax highlighting
Weaknesses
- A log-in is required
- The terminal cannot be set to the output of the board
- Trying to run code in the browser fails as it is set for standard Python
Now to contrast this with other online editors on the next page.
Text editor powered by tinymce.