这里写自定义目录标题
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)