[Diao Ye learns programming] Arduino hands-on (196) --- Raspberry Pi Pico development board 2

The reference to 37 sensors and modules has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensor and actuator modules on hand, in accordance with the concept of true knowledge (must be hands-on), for the purpose of learning and communication, here I am going to try and do more experiments one by one. Whether it is successful or not, it will be recorded ——Small progress or unsolvable problems, I hope to be able to throw bricks and spark jade.

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 196: Raspberry Pi Pico development board raspberry pi PICO dual-core RP2040 single-chip C++/Python programming entry-level controller

insert image description here
insert image description here

On January 21, 2021, the Raspberry Pi Foundation (Raspberry Pi Foundation) official website blog released the latest microcontroller development board: RaspBerry Pi Pico, which uses the first self-developed chip RP2040.

The RP2040 chip is manufactured by TSMC using a 40nm process. It adopts the Arm Cortex M0+ processor architecture with a running frequency of 133 MHz. It has 264K SRAM and 2MB onboard storage space, which largely solves the problems of analog input, low latency, and low power consumption. .

The Raspberry Pi Pico is based on the RP2040. According to the original design principles, PR2040 achieved three goals: first, high performance, especially for integer workloads; second, more flexible I/O, allowing communication with any external device; third, low cost.

insert image description here

Raspberry Pi pico development environment configuration

For the programming development of Pico, Pico C++/C++ SDK and Pico Python SDK software development kits are officially developed. Users can choose C/C++ or Python to develop Pico.

Programming and burning of Pico needs to be done on a computer. Supported operating systems and computers include:

Raspberry Pi with Raspberry Pi OS

Other platforms with Debian-based Linux systems

A computer running MacOS

Windows-based computers, etc.

Among them, as the son, the development environment configuration of Raspberry Pi 4B or Raspberry Pi 400 equipped with Raspberry Pi OS is the most convenient, and most of the configuration work can be completed by one line of setup script commands.

Pico adopts a very convenient drag-and-drop programming: connect Pico to the computer via USB, Pico will be recognized by the computer as a mass storage device, and programming files can be dragged and dropped into it to complete program burning.

insert image description here
Try to connect Pico to the computer via Micro-USB, open the computer device manager according to the old habit, check its connection port (worry whether you need to install the driver), and find that there is no port

insert image description here

Experimental scene graph

insert image description here

Later found the Pico board in the disk drive


insert image description here

Open my computer and add a new G drive

insert image description here

Open this drive, there are two files, a notepad, and a website link

insert image description here
insert image description here
Let's start to try the Arduino development environment, open IDE-tools-development board manager, search for "pico", and install the second one (see the red dot)

insert image description here

Select development board

insert image description here
First Test Program - Blinking an LED

The first program anyone writes when using a new microcontroller is to blink an LED. The Raspberry Pi Pico has an onboard LED (connected to GPIO pin 25).
You can turn this feature on and off in the following ways:

Download Blink UF2
Hold down the BOOTSEL button, then plug the Pico into a USB port on a Raspberry Pi or other computer.
It will be installed as a mass storage device named RPI-RP2.
Drag and drop the Blink UF2 binary onto the RPI-RP2 volume.
The Pico will reboot and the onboard LED should start blinking.

Download link: https://www.raspberrypi.org/documentation/rp2040/getting-started/static/85aac7081a166b7a3d0739970c3927c9/blink.uf2

Experimental scene graph

insert image description here
https://imagemc.dfrobot.com.cn/data/attachment/forum/202108/07/122207tnjs83u3cqi8zizi.gif

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
experiment one hundred and eighty-four: Raspberry Pi Pico development board raspberry pi PICO dual-core RP2040 single-chip C++/Python programming entry
one of the controller projects: blink flashing light

Experimental open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验一百八十四:树莓派Pico开发板 raspberry pi PICO双核 RP2040 单片机C++/Python编程入门控制器
  项目之一:blink闪灯
*/

#include "pico/stdlib.h"

int main() {
    
    
#ifndef PICO_DEFAULT_LED_PIN
#warning blink example requires a board with a regular LED
#else
  const uint LED_PIN = PICO_DEFAULT_LED_PIN;
  gpio_init(LED_PIN);
  gpio_set_dir(LED_PIN, GPIO_OUT);
  while (true) {
    
    
    gpio_put(LED_PIN, 1);
    sleep_ms(250);
    gpio_put(LED_PIN, 0);
    sleep_ms(250);
  }
#endif
}

Program Two, Show "Hello World"
The next program anyone can write is to say "Hello World" over a USB serial connection.

1. Download "Hello World" UF2.
2. Press and hold the BOOTSEL button, then plug the Pico into the USB port of the Raspberry Pi or other computer.
3. It will be installed as a mass storage device called RPI-RP2.
4. Drag and drop the "Hello World" UF2 binary onto the RPI-RP2 volume. Pico will restart
5. Open a terminal window and enter:

sudo apt install minicom

minicom -b 115200 -o -D /dev/ttyACM0

You should see "Hello, world!" printed to the terminal

Download link:
https://www.raspberrypi.com/documentation/microcontrollers/

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 184: Raspberry Pi Pico development board raspberry pi PICO dual-core RP2040 single-chip C++/Python programming entry controller
project 2: pass USB serial connection prints "Hello World"

Experimental open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验一百八十四:树莓派Pico开发板 raspberry pi PICO双核 RP2040 单片机C++/Python编程入门控制器
  项目之二:通过 USB 串行连接打印“Hello World”
*/

#include <stdio.h>
#include "pico/stdlib.h"

int main() {
    
    
  stdio_init_all();
  while (true) {
    
    
    printf("Hello, world!\n");
    sleep_ms(1000);
  }
  return 0;
}

Open the device manager on the computer and find that there is an extra port (see the red dot)

insert image description here

Project 2 serial port return

insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/132149699