CircuitPython
Quickstart-Guide Installing CircuitPython on a Teensy 4.0 Board
You need the CircuitPython-Firmware for the Teensy 4.0-Board.
The CiruitPython Firmware can be downloaded here:
Teensy 4.0 CircuitPython-firmware-Hexfile
Tool for uploading CircuitPython-Firmware
The manufacturer of the the teensy 4.0-Board provides a small software called teensy-loader which can be downloaded from here:
Teensy-Loader-Sowftare download
TEENSY.EXE is a single file application, so there is no installer required. You may copy it anywhere on your computer.
If you start the teensy-loader click on File - open Hexfile choose the circuitPython-HEX-file downloaded like described above
After choosing the PythonCircuit-Hexfile The Teensy-loader says press button to manually enter Program Mode Press the button and the firmware-hex-file gets uploaded into the flash-memory of the Teensy 4.0 Then there comes up a short message Reboot OK. After that you should here this typical sound of unplugging and plugging an USB-device and a new explorer-window of a drive named CIRCUITPY should popup
Reset your Teensy 4.0 to factory settings:
A Teensy 4.0 has a second µC that works as bootloader. This bootloader has a "reset-to-factory-settings"-feature. If you hold down the white button on the Teensy 4.0-Board for 15 seconds (not 13 seconds nor 17 seconds the bootloader will erase the complete flash-memory and store the Blink-OnBoard-LED program on it. If you release the white button after 15 seconds the tiny red LED turns on and after aproximately 20-30 seconds the resetting has finished and the organge OnBoard-LED should start blink one second on/ one second off.
programming your teensy 4.0
Now programming your teensy 4.0 with python works this way: You can edit a pythonfile with whatever editor you like and save it on the CIRCUITPY-drive The program shall be executed automatically it must have the filename code.py
You can store other python-programs with other names but they don't get exectuted automatically
For executing another program once you can manually execute any file from the Read Evaluate Print Loop (in short REPL) by typing import yourfilename if you have a file named yourfilename.py on the board. It will run only once If you press-Ctrl-C it will be stopped. Then you would have to press Ctrl-D to leave REPL which would start the file code.py then press Ctrl-C again. But then all previous manual typed commands are no longer saved.