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

# 本作品采用MIT许可证授权。
# Copyright (c) 2013-2026 OpenMV LLC. All rights reserved.
# 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 and P8 share TIM4 so they need to have the same frequency.
p7 = PWM("P7", freq=100, duty_u16=32768)
p8 = PWM("P8", freq=100, duty_u16=32768)

# P9 (TIM17) and P10 (TIM15) each use their own timer.
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 ""