使用Phonny开发Raspberry Pi Pico

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

MCU用来用去还得是Raspberry Pi系列,语言选来选去还得是MicroPython,对于初学者来讲太友好了。虽然我是一个高级C++开发,还是感慨Python的上手很容易,学习成本很低。


一、MicroPython是什么?

官方网站

MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments.

The MicroPython pyboard is a compact electronic circuit board that runs MicroPython on the bare metal, giving you a low-level Python operating system that can be used to control all kinds of electronic projects.

MicroPython is packed full of advanced features such as an interactive prompt, arbitrary precision integers, closures, list comprehension, generators, exception handling and more. Yet it is compact enough to fit and run within just 256k of code space and 16k of RAM.

MicroPython aims to be as compatible with normal Python as possible to allow you to transfer code with ease from the desktop to a microcontroller or embedded system.

简而言之,为MCU专门开发的Python,可以运行在资源紧张的设备上。学习上手难度又没有C和C++那么难。

二、使用步骤

1.下载Phonny IDE

官方网站

在这里插入图片描述

选则自己的操作系统版本下载并安装

2.安装MicroPython固件

Raspberry Pi Pico要使用MicroPython需要先安装MicroPython固件到设备上。

第一步:
准备一条USB数据线一头先接到电脑USB口上。

第二步:
按住Raspberry Pi Pico上的BOOT按钮不松并将USB另一头插到Raspberry Pi Pico的USB口上(一啊般是Micro USB或Type-C)。
在这里插入图片描述

这个时候你的电脑上出现一个U盘,如果没出现就检查系下电脑USB驱动或设备问题。在这里插入图片描述第三步:
打开Phonny软件并在右下角找到你的设备(串口转USB)并安装MicroPython解释器,等待完成。

在这里插入图片描述
在这里插入图片描述

3.测试Demo

MicroPython固件烧录完成后拔下USB并重新插上(不需要按BOOT)就进入开发模式了。

写一个LED闪烁的Demo:

from machine import Pin,Timer

led = Pin(25,Pin.OUT)
timer = Timer()

def blink(timer):
    led.toggle()

timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink)

点击运行并选则推送到设备上

在这里插入图片描述

这个时候Raspberry Pi Pico上的LED灯就开始闪烁了。


总结

1、几乎没什么难度

  • 8
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值