How to Fix LED Not Responding to PWM Signals on BeagleBone Black?

Hey guys, am developing a lighting control system using a BeagleBone Black running Embedded Linux using microcontroller(AM335x ARM Cortex-A8). The system needs to control the brightness of an LED using PWM. i have ensured that the Adafruit_BBIO library is correctly installed and imported in your script, adjusted the PWM.set_duty_cycle() values to ensure they are within the valid range (0-100). but i keep encountering errors such as the LED not responding to PWM signals.
   import Adafruit_BBIO.PWM as PW
   import time

   # Define PWM pin
   PWM_PIN = "P9_14"

   # Initialize PWM
   PWM.start(PWM_PIN, 0)  # Start with 0% duty cycle

   def set_brightness(brightness):
       # Set PWM duty cycle (brightness)
       PWM.set_duty_cycle(PWM_PIN, brightness)

   try:
       while True:
           for brightness in range(0, 101, 5):  # Increase brightness
               set_brightness(brightness)
               print(f"Brightness: {brightness}%")
               time.sleep(0.1)

           for brightness in range(100, -1, -5):  # Decrease brightness
               set_brightness(brightness)
               print(f"Brightness: {brightness}%")
               time.sleep(0.1)

   except KeyboardInterrupt:
       print("\nExiting...")

   finally:
       PWM.stop(PWM_PIN)
       PWM.cleanup()
file0.jpg
Was this page helpful?