Code circuitpython with mu en

From Banana Pi Wiki
Revision as of 01:42, 29 September 2022 by Wind (talk | contribs) (Establish the connection)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Hardware Preparation

1. Mu editor supports Windows x64, Mac OSX, Linux operating systems, prepare a computer running one of these operating systems.

2. A development board that supports CircuitPython, such as BPI-PicoW-S3.

3. A USB cable that can connect the development board to the computer.

Download and install Mu Editor

1. Open the Mu editor web page and click the Download button to enter the new page.

Download mu 1.png

2. Select the operating system currently used by your computer, and click the Download button corresponding to the operating system to start downloading the installation package.

Download mu 2.png

3. Click the Instuctions button of the corresponding operating system to view the detailed installation steps, and install according to the instructions.

Establish the connection

1. Start the Mu editor and change the mode to CircuitPython, if you have connected the CircuitPython development board correctly, you will be prompted whether to switch to this mode directly.

Download mu 3.png

Download mu 4.png

2. Click the Serial button and press any key to enter the CircuitPython REPL.

Download mu 5.png

Edit to make the LED blink

1. Click the Load button, select the file on the CircuitPython development board, and click Open to start editing .

2. Enter the following code in the editor:

import time
import board
import neopixel

pixels = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1)

while 1:
    pixels[0] = (255,0,0)
    pixels[0] = (0,255,0)
    pixels[0] = (0,0,255)
    pixels[0] = (255,255,255)

3. Click the Save button, and the edited content will be saved to the CircuitPython development board.

If the code is correct, the full color LED on the development board will twinkle red, green, blue, and white cyclically.