输入输出引脚

同一引脚可以用作输入/输出,程序控制的行为:

上/下拉电阻

若没有上下拉电阻,无法读取引脚的高低电平的状态,因此它的作用即为确定引脚的状态

HW480 双色led

HW484磁簧开关(未做)

HW479 三色LED

HW501 倾斜开关(未)

HW483 按钮开关

HW493 激光发射

HW507温湿度

import utime, random
from machine import Pin, PWM
Red = Pin(16, machine.Pin.OUT)
Green = Pin(17, Pin.OUT)
ch = PWM(Pin(25)) # PWM at GP25
ch.freq(1000) # Frequency = 1000Hz
i = 0
while True:
    ch.duty_u16(5000) # Change duty cycle
    utime.sleep_ms(300) # Delay 300ms
    r = random.randint(0, 1)
    g = random.randint(0, 1)
    Red.value(r)
    utime.sleep(0.01)
    Green.value(g)
    utime.sleep(0.01)