3

I want to set the PWM for some tests with a tricolored LED. I want to be able to set it up via the sysfs interfaces but I'm having a very hard time finding any information on how to do this.

What is available to interface with the Raspberry Pi's PWM (GPIO18) without the use of external libraries? (ie WiringPi and friends)

Note: I'm using the Raspbian linux distribution

2 Answers 2

2

I'm not sure that the GPIO SYSFS export actually supports PWM. Servoblaster provides a SYSFS like interface through /dev/servoblaster for controlling PWM, e.g.:

echo PINNUMER=10% > /dev/servoblaster

If you want something internal to a program, the next best bet is accessing /dev/mem directly to control the GPIO. Frank Buß has written some demo code for this. It's quite complex, so unless you really need something stand-alone, I'd recommend the Servoblaster approach.

0

Or enable a proper sysfs using device tree:

https://jumpnowtek.com/rpi/Using-the-Raspberry-Pi-Hardware-PWM-timers.html

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.