timer1 用不了,因为摄像头采集用了timer1
import sensor, image, time
from pyb import Pin, Timer
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
tim = Timer(2, freq=1000) # Frequency in Hz
ch3 = tim.channel(3, Timer.PWM, pin=Pin("P4"), pulse_width_percent=50)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
print(clock.fps())