Difference between revisions of "Circuitpython"

From Sketching with Hardware at LMU Wiki
Jump to navigation Jump to search
Line 5: Line 5:
 
Go to [https://circuitpython.org/downloads circuitpython.org/downloads] and download the version for your board.
 
Go to [https://circuitpython.org/downloads circuitpython.org/downloads] and download the version for your board.
  
For the Raspberry PI Pico connect the board to the computer and the folder RPI-RP2 shows ups in your file system. For the Arduino Nano Connect RP2040 [https://www.sketching-with-hardware.org/wiki/Arduino_Nano_RP2040_Connect#Install_the_Arduino_Nano_RP2040_Connect_Firmware force the bootloder mode]
+
For the Raspberry PI Pico connect the board to the computer and the folder RPI-RP2 shows ups in your file system. For the Arduino Nano Connect RP2040 [https://www.sketching-with-hardware.org/wiki/Arduino_Nano_RP2040_Connect#Install_the_Arduino_Nano_RP2040_Connect_Firmware force the bootloder mode] to upload the .uf2 file.
  
 
Copy the .uf2 into the folder of the board.
 
Copy the .uf2 into the folder of the board.

Revision as of 09:39, 22 June 2024

Introduction and step by step tutorial from Adafruit

Installing CircuitPython

Go to circuitpython.org/downloads and download the version for your board.

For the Raspberry PI Pico connect the board to the computer and the folder RPI-RP2 shows ups in your file system. For the Arduino Nano Connect RP2040 force the bootloder mode to upload the .uf2 file.

Copy the .uf2 into the folder of the board.

Now you should be able to connect to the board and use the editor.

If you need more help, here is a more detailed description on the installation process at adafruit.com

CircuitPy Drive

After installing CircuitPython on the board and reconnecting the board, it should show up as a USB drive on your computer with the name CircuitPy.

Here you can directly access the code you write and data you safe from your programs.

As the board is a USB drive do not just unplug it - use "safe remove" feature of your OS.

Running your first CircuitPython Program

In the file system of the board (that shows up as USB Drive CIRCUITPY) there is a file code.py.

To write your program, open code.py and edit it with your code. Once you safe it, it will be automatically excuted. The file name must be code.py or main.py.

Try it out with the following program. Just use any editor and open code.py. Replace it with the following code and you should see the LED flash. Changes the sleep times. Each time you safe it the new program will be active:

 1 # write on serial line and blink onbaord LED
 2 import board
 3 import digitalio
 4 import time
 5 
 6 led = digitalio.DigitalInOut(board.LED)
 7 led.direction = digitalio.Direction.OUTPUT
 8 
 9 while True:
10     led.value = False
11     time.sleep(0.8)
12     led.value = True
13     time.sleep(0.2)

Install the Mu Editor

Follow the instructions for installting the Mu Editor.

  • Install it on your system
  • On first start up select CircuitPython as Mode
  • Test if it works in the CircuitPython REPL console