901 views|1 replies

274

Posts

8

Resources
The OP
 

[Digi-Key Follow me Issue 1] First Post - Building a Development Environment [Copy link]

 

Raspberry Pi Pico W is a development board with wireless function based on the Raspberry Pi RP2040 chip. Pico can be developed under multiple operating systems, such as Windows, Linux, etc. Pico officially supports the development method of MicroPython. Using MicroPython can take advantage of Python's syntax features and can run directly without compilation. It also provides many library functions, which can quickly get started.

Let's talk about how to use MicroPython on Pico. The overall steps mainly include 2 steps:

  1. First you need to download the MicroPython firmware on Pico
  2. Then build the development environment

The details are as follows:

1. Download MicroPython firmware

1.1 Download the official MicroPython firmware

The MicroPython firmware download address for Pico W is:

https://micropython.org/download/rp2-pico-w/rp2-pico-w-latest.uf2

If you are using Pico, you need to download the following firmware:

https://micropython.org/download/rp2-pico/rp2-pico-latest.uf2

Note that the 2 firmwares are different.

1.2 Burning firmware The official MicroPython firmware is available at:

Follow these steps to burn the firmware to the Pico:

  1. Press the 'BOOTSEL' button on the board and then power on;
  2. At this point the computer will recognize Pico as a USB drive and copy the downloaded firmware to the USB drive.

Reference: MicroPython page on Pico official website

2. Build the development environment

Now that the Pico board that supports MicroPython is ready, the next step is to build a development environment. The official recommendation is Thonny IDE, which is a very small Python integrated development tool with a size of only 20MB. This IDE has a built-in Pico interpreter and can directly write Pico code.

First download the latest installation package from the official website: Thonny, Python IDE for beginners

After the installation is complete, you need to switch the software to the MicroPython interpreter that supports Pico. Click "Tools->Options" in the menu bar, open "Thonny Options", and select "MicroPython (Raspberry Pi Pico)" in the "Interpreter" tab, as shown below:

At this point, the Pico development board will automatically connect when it is connected to the computer.

3. Write test code

The editing interface of Thonny IDE is shown in the figure above. You can edit the code in the form of files in the editor above, or you can edit the code in the interactive form in "Shell". For example, output "Hello world"

print("Hello world")

You can directly see the running results in Shell. If you edit it in file form, you need to click the "Run current script" button.

You can also write code to flash the LED. The code is as follows:

from machine import Pin 
from utime import sleep 
pin = Pin("LED",Pin.OUT) 
print("LED starts flashing...") 
while True: 
    pin.toggle() 
    sleep(1)

IV. Summary

Now we can use MicroPython to program Pico. However, Thonny IDE does not have the function of code completion, so in order to pursue programming efficiency, we can use VS Code. The next post will introduce how to use VS Code.

This post is from DigiKey Technology Zone

Latest reply

Downloading MicroPython firmware is a bit slow, and I don't know how big the file is.   Details Published on 2023-5-23 07:32
 
 

6570

Posts

0

Resources
2
 

Downloading MicroPython firmware is a bit slow, and I don't know how big the file is.

This post is from DigiKey Technology Zone
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list