Example: 50-OpenMV-Boards/50-IMXRT-Boards/50-Board-Control/pwm_control.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2024 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2024 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 machine import PWM

# P7和P8可能共享同一个PWM模块,它们需要
# 具有相同的频率。
p7 = PWM("P7", freq=100, duty_u16=32768)
p8 = PWM("P8", freq=100, duty_u16=32768)

# P9和P10可能共享同一个PWM模块,它们需要
# 具有相同的频率。
p9 = PWM("P9", freq=100, duty_u16=32768)
p10 = PWM("P10", freq=100, duty_u16=32768)

while True:
    for i in range(0, 65536, 256):
        p7.duty_u16(65535 - i)
        time.sleep_ms(10)
    p7.duty_u16(32768)

    for i in range(0, 65536, 256):
        p8.duty_u16(65535 - i)
        time.sleep_ms(10)
    p8.duty_u16(32768)

    for i in range(0, 65536, 256):
        p9.duty_u16(65535 - i)
        time.sleep_ms(10)
    p9.duty_u16(32768)

    for i in range(0, 65536, 256):
        p10.duty_u16(65535 - i)
        time.sleep_ms(10)
    p10.duty_u16(32768)

results matching ""

    No results matching ""