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/
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, 禁止轉載 🈲️,侵權必究⚠️!