|
NUCLEO_L476开发板的LED是PA5,它也是PWM2/1的输出,所以我们可以使用PWM来控制LED的亮度。下面演示了在MicroPython中使用PWM控制LED亮度的方法:
- >>> MicroPython v1.8 on 2016-05-10; NUCLEO-L476RG with STM32L476
- Type "help()" for more information.
- >>> from pyb import Pin, Timer
- >>> tm = Timer(2, freq=1000)
- >>> led = tm.channel(1, Timer.PWM, pin=Pin.cpu.A5)
- >>> led.pulse_width_percent(10)
- >>> led.pulse_width_percent(50)
- >>>
复制代码
|
|