Examples
Create a new folder for your source code, e.g. in
~/Documents/testand change into that directory:mkdir ~/Documents/test cd ~/Documents/test
In an editor, create a new file named
code.pyin the above folder with the following contents:from time import sleep i = 0 while True: print(f"hello world: {i}") sleep(1) i += 1
Enable shell completion to make the subsequent commands easier:
eval $(circuitpython-tool completion)
List connected CircuitPython devices to figure out the device naming:
circuitpython-tool devicesThe connected device has a
modelvalue ofPico_W. To refer to this device in subsequent commands, we can use the device syntax of:Pico:. Alternatively, if you only have one device connected to your computer, you can just use the wildcard::value.Use
circuitpython-toolto upload code:circuitpython-tool upload :Pico: --mode=watch
The
:Pico:argument refers to the Raspberry Pi Pico W we found using. thecircuitpython devicescommand. The--mode=watchoption keeps the program continuously running and waiting for file changes. You can exit it at any time using Control-COpen a new terminal window and connect to your device’s serial terminal:
circuitpython-tool connect :Pico: