Pico使用
Posted 勾小芬
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Pico使用相关的知识,希望对你有一定的参考价值。
这里写自定义目录标题
UART
https://blog.csdn.net/weiqifa0/article/details/114696022
from machine import UART, Pin
import utime
uart = UART(0, baudrate=115200, bits=8, parity=None, stop=1, tx=Pin(0), rx=Pin(1))
sendStr = ""
receiveStr = ""
if uart.any:
uart.write(sendStr.encode())
receivestr = uart.readline().decode()
ADC:读取Pico芯片内部温度
from machine import ADC
import utime
sensor_temp = machine.ADC(4)
conversion_factor = 3.3/65535
while True:
read = sensor_temp.read_u16() * conversion_factor
temperature = 27 - (read - 0.706) / 0.001721
print(temperature)
utime.sleep(2)
PWM驱动板载LED
form machine import Pin, PWM
import time
pwm = PWM(pin(25))
pwm.freq(1000)
duty = 0
direction = 1
for _ in range(16*255):
duty += direction
if duty > 255:
duty = 255
direciton = -1
elif duty < 0:
duty = 0
direction = 1
pwm.duty_u16(duty*duty)
time.sleep(0.001)
以上是关于Pico使用的主要内容,如果未能解决你的问题,请参考以下文章
Raspberry pi pico|为Raspberry Pi Pico添加重置按钮(pico烧录程序不再插拔数据线!)