Page 1 of 1

【Luckfox Pico Ultra W】无法通过PWM引脚控制LED灯

Posted: 2025-06-27 15:31
by hartvon
Hello, Luckfox 团队:

我正在测试通过PWM引脚控制LED,注意到Pico Ultra W设备上似乎只有一个LED电源灯。
运行示例 控制PWM(Python程序),没看到明显的LED灯呼吸效果。
使用自己的程序(控制LED灯常亮),也看不到期望的效果,如下是我的程序:

Code: Select all

from periphery import PWM
import time

pwm = PWM(10, 0)

try:
    # Configure PWM for constant on
    pwm.frequency = 1000      # Frequency (not critical for constant on)
    pwm.duty_cycle = 1.0      # 100% duty cycle = fully on
    pwm.polarity = "normal"   # Normal polarity
    pwm.enable()             # Enable PWM output

    print("LED is now constantly on at full brightness")
    print("Press Ctrl+C to exit")

    while True:
        time.sleep(1)  # Keep program running

except KeyboardInterrupt:
    print("\nTurning off LED...")

finally:
    # Cleanup
    pwm.duty_cycle = 0  # Turn off LED
    pwm.close()
- 板子型号:Luckfox Pico Ultra W
- 镜像类型:Luckfox_Pico_Ultra_W_EMMC_0429

想请问下问题出现了哪里,是需要增加额外的LED灯,还是需要使用其他的PWM引脚,期待您的答复!

Re: 【Luckfox Pico Ultra W】无法通过PWM引脚控制LED灯

Posted: 2025-06-30 1:37
by Crocodile
您好, PWM10_M0 对应的引脚为GPIO3_A4, 在Luckfox Pico Ultra 上用于连接无线模组,不是LED灯对应的GPIO3_C6.同时默认已经有驱动占用GPIO3_C6引脚,需用用于PWM测试还需要关闭相关的设备树(leds节点设置为disabled),只是用于测试的话建议使用其他引脚外接LED使用