Run your first code – Blinking led
Objective
- Install CircuitPython on your Raspberry Pi Pico
- Install Mu (Editor)
- Run your first code (Blinking Led)
CircuitPython for your Raspberry Pi Pico
This resume is base on the following Guide https://learn.adafruit.com/welcome-to-circuitpython.
To start coding the Raspberry Pi Pico initially, we need to flash the Firmware of Circuit Python. In the following image, you can see the content of the new board when you connect it to your computer for the first time (in my case, I am using macOS 11.6).
Install the firmaware of CircuitPython
After connecting the Raspberry Pi Pico to your computer, you need to install the new CircuitPython firmware here: https://circuitpython.org/board/raspberry_pi_pico/ . The file you require has the extension UF2. At this moment, the newest version is 7.0 or adafruit-circuitpython-raspberry_pi_pico-en_US-7.0.0.uf2.
Now you only need to Drag and Drop it into the Raspberry Pi Pico folder (RPI-RP2), and you will see how the folder changes the name to CIRCUITPY. Congratulation, now you have installed the Firmware, which allows the Raspberry Pi Pico to understand Python Code (CircuitPython).
Install MU editor
Go to https://codewith.mu/ and download the Mu Editor for your respective Operating System. Install this editor, as usual, and remember to give it the corresponding permissions (mac system) to read and write on every folder. The first time you lunch Mu editor, you will see the following screens.
Running your first Python program
Here you will only copy and paste the code. Next, you only need to save the program into your board with the name code.py, and immediately the code will be written into the Raspberry Pi Pico.
Eres un tutor optimista y alentador que ayuda a los estudiantes universitarios de la materia de electricidad y magnetismo a comprender conceptos explicando ideas y haciendo preguntas. Comienza por presentarte al estudiante como su tutor de inteligencia artificial (AI-Tutor), quien está feliz de ayudarlos con cualquier pregunta.
With this code, you will have a Blinking green led located next to the USB connector of your Pico board.
To change the blinking time of your led, change the values time.sleep(1) and use :
- time.sleep(1)
- time.sleep(0.5)
- time.sleep(0.1)
And every time you change it, save the file again and see how the led changes its blinking behavior.