use macOS terminal can not install MicroPython on Raspberry Pi Pico bug All In One
use macOS terminal can not install MicroPython on Raspberry Pi Pico bug All In One
使用 macOS 终端无法在 Raspberry Pi Pico 上安装 MicroPython bug
MicroPython 环境搭建
您可以通过 USB
将 Pico 连接到计算机,然后将文件拖放
到它上面来对 Pico 进行编程,因此我们整理了一个可下载的 UF2
文件,让您可以更轻松地安装
MicroPython。
- Command Line ❌
macOS ❌
Thonny IDE
✅
thonny-4.0.2.pkg ✅
pdf
ebooks
- SDK 文档
2.3. Connecting from a Mac ❌ (Page 10)
# 安装
$ brew install minicom
# 连接
$ minicom -b 115200 -o -D /dev/tty.usbmodem0000000000001
https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf
- Get Started with MicroPython on Raspberry Pi Pico (
RPi_PiPico_Digital_v10.pdf
)
- Installing MicroPython ❌ (Page 16)
https://hackspace.raspberrypi.com/books/micropython-pico
https://hackspace.raspberrypi.com/books
(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
Thonny IDE
led.py
#!/usr/bin/env python3
# coding: utf8
from machine import Pin
import time
led = Pin("LED", Pin.OUT)
led.low()
time.sleep_ms(500)
print("开始 👻")
n = 3
i = 0
while (i < n):
print("i =", i)
led.high()
time.sleep_ms(1000)
led.low()
time.sleep_ms(1000)
i += 1
print("结束 ✅")
"""
# bug version ❌
while True:
led.high()
time.sleep_ms(500)
led.low()
time.sleep_ms(500)
"""
#!/usr/bin/env python3
# coding: utf8
from machine import Pin
from time import sleep
# 内置 LED 通过 GPIO 25 连接
GPIO_PIN = 25
led = Pin(GPIO_PIN, Pin.OUT)
led.value(0)
i = 0
n = 3
print("begin 💡")
while i <= 3:
print("i =", i)
led.value(1)
sleep(1)
led.value(0)
sleep(1)
i += 1
print("finished 🚀")
"""
from machine import Pin
import time
# 内置 LED 通过 GPIO 25 连接
# 1
Pin(25, Pin.OUT).value(1)
time.sleep_ms(1000)
Pin(25, Pin.OUT).value(0)
# 2
Pin(25, Pin.OUT).value(1)
time.sleep_ms(1000)
Pin(25, Pin.OUT).value(0)
# 3
Pin(25, Pin.OUT).value(1)
time.sleep_ms(1000)
Pin(25, Pin.OUT).value(0)
"""
https://electrocredible.com/raspberry-pi-pico-with-macos-thonny-getting-started/
https://microcontrollerslab.com/getting-started-raspberry-pi-pico-thonny-ide/
tty.usbmodem
编号错误 ❌
# 连接 tty.usbmodem14601 ❌
$ minicom -b 115200 -o -D /dev/tty.usbmodem14601
# 连接 cu.usbmodem14601 ✅
$ minicom -b 115200 -o -D /dev/cu.usbmodem14601
minicom 如何使用的 ???
卡死了 ❌ 好难用呀 💩
Ctrl + B 一顿乱按不知道怎么就进来了❓
>>> help()
Welcome to MicroPython!
For online help please visit https://micropython.org/help/.
For access to the hardware use the 'machine' module. RP2 specific commands
are in the 'rp2' module.
Quick overview of some objects:
machine.Pin(pin) -- get a pin, eg machine.Pin(0)
machine.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
methods: init(..), value([v]), high(), low(), irq(handler)
machine.ADC(pin) -- make an analog object from a pin
methods: read_u16()
machine.PWM(pin) -- make a PWM object from a pin
methods: deinit(), freq([f]), duty_u16([d]), duty_ns([d])
machine.I2C(id) -- create an I2C object (id=0,1)
methods: readfrom(addr, buf, stop=True), writeto(addr, buf, stop=True)
readfrom_mem(addr, memaddr, arg), writeto_mem(addr, memaddr, arg)
machine.SPI(id, baudrate=1000000) -- create an SPI object (id=0,1)
methods: read(nbytes, write=0x00), write(buf), write_readinto(wr_buf, rd_buf)
machine.Timer(freq, callback) -- create a software timer object
eg: machine.Timer(freq=1, callback=lambda t:print(t))
Pins are numbered 0-29, and 26-29 have ADC capabilities
Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT
Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN
Useful control commands:
CTRL-C -- interrupt a running program
CTRL-D -- on a blank line, do a soft reset of the board
CTRL-E -- on a blank line, enter paste mode
For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')
>>>
Minicom
>>> help()
Welcome to MicroPython!
For online help please visit https://micropython.org/help/.
For access to the hardware use the 'machine' module. RP2 specific commands
are in the 'rp2' module.
Quick overview of some objects:
machine.Pin(pin) -- get a pin, eg machine.Pin(0)
machine.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
methods: init(..), value([v]), high(), low(), irq(handler)
machine.ADC(pin) -- make an analog object from a pin
methods: read_u16()
machine.PWM(pin) -- make a PWM object from a pin
methods: deinit(), freq([f]), duty_u16([d]), duty_ns([d])
machine.I2C(id) -- create an I2C object (id=0,1)
methods: readfrom(addr, buf, stop=True), writeto(addr, buf, stop=True)
readfrom_mem(addr, memaddr, arg), writeto_mem(addr, memaddr, arg)
machine.SPI(id, baudrate=1000000) -- create an SPI object (id=0,1)
methods: read(nbytes, write=0x00), write(buf), write_readinto(wr_buf, rd_buf)
machine.Timer(freq, callback) -- create a software timer object
eg: machine.Timer(freq=1, callback=lambda t:print(t))
Pins are numbered 0-29, and 26-29 have ADC capabilities
Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT
Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN
Useful control commands:
CTRL-C -- interrupt a running program
CTRL-D -- on a blank line, do a soft reset of the board
CTRL-E -- on a blank line, enter paste mode
For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')
>>> pin25 = machine.Pin(25)
>>> print("pin25 =", type(pin25))
pin25 = <class 'Pin'>
>>> GPIO_PIN = 25
>>> led = machine.Pin(GPIO_PIN, machine.Pin.OUT)
>>> print(type(led))
<class 'Pin'>
>>> led.value(1)
>>> time.sleep(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'time' isn't defined
>>> import time
>>> time.sleep(1)
>>> from time import sleep
>>> sleep(1)
>>> led.value(0)
>>> led.high()
>>> led.low()
>>>
Meta-Z for help | 115200 8N1 | NOR | Minicom 2.8 | VT102 | Offline | cu.usbmodem14601
minicom
Minicom is a text-based
modem control and terminal emulator
program for Unix-like operating systems, originally written by Miquel van Smoorenburg, and modeled somewhat after the popular MS-DOS program Telix but is open source.
Minicom 是用于类 Unix 操作系统的基于文本
的调制解调器控制和终端仿真器
程序,最初由 Miquel van Smoorenburg 编写,有点模仿流行的 MS-DOS 程序 Telix,但它是开源的。
https://en.wikipedia.org/wiki/Minicom
https://wiki.emacinc.com/wiki/Getting_Started_With_Minicom
https://man7.org/linux/man-pages/man1/minicom.1.html
https://linux.die.net/man/1/minicom
# 抓取 tty ???
$ dmesg | grep tty
https://help.ubuntu.com/community/Minicom
Minicom is a serial communication
program
minicom 是一个串口通讯
程序
https://salsa.debian.org/minicom-team/minicom
minicom 的退出按键是 Ctrl+a-q
https://sites.google.com/site/readliner/study/arm-linux/minicom
http://ftp.pld-linux.org/pool/m/minicom/
raspi-config
# GUI 交互式命令行界面
$ sudo raspi-config
在本质上还是直接修改 /boot/config.txt
配置文件
https://www.raspberrypi.com/documentation/computers/configuration.html#the-raspi-config-tool
refs
https://www.cnblogs.com/xgqfrms/p/17274289.html
https://github.com/xgqfrms/Raspberry-Pi/tree/master/Pico
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17274811.html
未经授权禁止转载,违者必究!