logo

AttributeError:'module' obiect has no attribute 'PWM?

2025-07-07 11:41
T
emnb

#固件已经更新4.6.20这咋回事?

import time
import machine

# P7 和 P8 可以共享相同的 PWM  module,它们需要具有相同的频率。
p7 = machine.PWM("P7", freq=50, duty_ns=(2000 * 1000))
while True:
    for i in range(1000, 2000, 100):
        p7.duty_ns(i * 1000)
        time.sleep_ms(1000)

    for i in range(2000, 1000, -100):
        p7.duty_ns(i * 1000)
        time.sleep_ms(1000)
2025-07-10 15:06
Z
星小瞳xs

H7 和 H7 PLUS用pyb,RT才是machine