Micropython应用篇四—F407VE Black开发板IO PWM
开发板PWM定义如下(即支持定时器):
以PA15为例,代码如下:
# main.py -- put your code here!
import time
from pyb import Pin, Timer
tm2=Timer(2,freq=100)
led3=tm2.channel(1,Timer.PWM, pin=Pin.cpu.A15)
for i in range (100):
led3.pulse_width_percent(i)
time.sleep_ms(500)
默认PWM最大值为65535,这里代码将PWM定义改为100,LED渐变亮度。