Example: 50-OpenMV-Boards/50-STM32-Boards/50-Board-Control/pwm_control.py
# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# PWM 控制示例
#
# This example shows how to do PWM with your OpenMV Cam.
import time
from pyb import Pin, Timer
tim = Timer(4, freq=1000) # 频率(Hz)
# Generate a 1KHz square wave on TIM4 with 50% and 75% duty cycles on channels 1 and 2 respectively.
ch1 = tim.channel(1, Timer.PWM, pin=Pin("P7"), pulse_width_percent=50)
ch2 = tim.channel(2, Timer.PWM, pin=Pin("P8"), pulse_width_percent=75)
while True:
time.sleep_ms(1000)