Circuit Python - TeensyUser/doc GitHub Wiki

Download CircuitPython-Firmware:

here the CiruitPython Firmware can be downloaded: https://circuitpython.org/board/teensy40/

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: https://www.pjrc.com/teensy/loader.html

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 hear 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 approximately 20-30 seconds the resetting has finished and the orange OnBoard-LED should start blink one second on/ one second off.

the pythoncode must have the name code.py to get executed automatically

Now programming your teensy 4.0 with python works this way: You can edit a python file 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 executed automatically.

So here is the "Hello World I link demo-code

import board
import digitalio
import time

led = digitalio.DigitalInOut(board.D13)    
                                           
led.direction = digitalio.Direction.OUTPUT 
duration = 0.1                             

print('Hello World!')                      

while True:                              
    led.value = True                       
    time.sleep(duration)                   
    
    led.value = False                      
    time.sleep(duration)                   `

Only the filename code.py the code gets executed automatically

here is a link to a link-collection with information that gets deeper into it https://forum.pjrc.com/threads/59040-CircuitPython-on-Teensy-4!