pwm_control.py
# この作品はMITライセンスの下で提供されています。
# Copyright (c) 2013-2023 OpenMV LLC. 全著作権所有。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# PWM制御の例
#
# この例では、OpenMV CamでPWMを行う方法を示します。
import time
from pyb import Pin, Timer
tim = Timer(4, freq=1000) # 周波数(Hz)
# TIM4上に1KHzの矩形波を、チャンネル1で50%、チャンネル2で75%のデューティ比で生成します。
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)