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()

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()

attachment 0
4 Replies
melta101
melta1015mo ago
Could you try with another PWM channel
melta101
melta1015mo ago
i think PWM channel driver is still using it
Boss lady
Boss lady5mo ago
Okay would try that now @melta101
RED HAT
RED HAT5mo ago
@Boss lady Make sure that the PWM pin (P9_14) is correctly configured for PWM output and that there are no conflicts with other peripherals. check the BeagleBone Black pin configuration in the device tree and : You can use the config-pin utility to configure the pin for PWM. Try running the following command in the terminal:
config-pin P9_14 pwm
config-pin P9_14 pwm
Make sure you get no errors when running this command.
Want results from more Discord servers?
Add your server