Raspberry Pi PICO configuration tutorial-hello world, basic tutorial, how to configure Raspberry Pi pico, raspberry pico (based on MicroPython)

1 Introduction to Raspberry Pi PICO

1.1 Introduction

The Raspberry Pi Pico is a low-cost, high-performance microcontroller board with a flexible digital interface. It integrates Raspberry Pi's own RP2040 microcontroller chip, a dual-core Arm Cortex M0+ processor running at up to 133 MHz, embedded 264KB SRAM and 2MB of onboard flash memory, and 26 multi-function GPIO pins. For software development, you can use the Raspberry Pi's C/C++ SDK or MicroPython.

1.2 Configuration

Insert image description here

1.3 Pin diagram

Insert image description here

1.4 Dimensions

Insert image description here

2 installation

2.1 Burn firmware

  1. Click the https://micropython.org/download/rp2-pico/rp2-pico-latest.uf2 link to download the UF2 file;

  2. If the connection fails, you can download it from the official website https://www.raspberrypi.org/documentation/rp2040/getting-started/#getting-started-with-micropython

  3. Press and hold the BOOTSEL button and insert the Pico into the USB serial port of the computer. A new U disk folder will pop up on the computer. Drag the UF2 file just downloaded into the folder. The Raspberry Pi PICO will automatically restart. When, the firmware burning is completed.

2.2 Install IDE (Thonny IDE) - Install on the host side

  1. Go to the official software website https://thonny.org/ to download the software. It is best to download the latest version, otherwise it may not support Raspberry Pi PICO;
  2. Install Thonny. After the installation is complete, open the Thonny software, open it 工具->设置-> 解释器, select MicroPython(Raspberry Pi Pico)the interpreter, and select the serial port number of the Raspberry Pi PICO at the serial port (if the board is connected to the computer, the software will generally automatically detect the serial port number)
  3. Restart the software and you can see that the files in the Raspberry Pi PICO are displayed in the lower left corner of the software;
    if the file tree on the left is not displayed, you can check View->File

2.3 Running the program offline

Insert image description here
Create a new file. After writing the code, hold down ctrl+s to save the file on the Raspberry Pi PICO and name it main.py (be sure to add the suffix .py). The next time the Raspberry Pi PICO is powered on, it will automatically Run the program in main.py.

3 hello-world lights up

3.01 Light up the onboard LED light

from machine import Pin

if __name__ == '__main__':
    # 构建led对象
    # 板载LED灯连接与引脚25相连
    # LED = Pin(id, mode, pull)
    # id:PICO引脚编号
    # mode:输入输出方式,有Pin.IN(输入)和Pin.OUT(输出)两种
    # pull:上下拉电阻配置,有None(无上下拉电阻)、Pin.PULL_UP(上拉电阻)和Pin.PULL_DOWN(下拉电阻)三种
    LED = Pin(25, Pin.OUT)
    # 高电平点亮
    LED.value(1)

3.02 Onboard LED flashes

from machine import Pin
from utime import sleep
import utime

led = Pin(25, Pin.OUT)

if __name__ == '__main__':
    while True:
        # led点亮
        led.value(1)
        utime.sleep_ms(1000)
        # led熄灭
        led.value(0)
        utime.sleep_ms(1000)

Guess you like

Origin blog.csdn.net/weixin_39589455/article/details/132045889