O'Reilly logo

Internet of Things with Python by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controlling PWM with the wiring-x86 library

So far, we have been using the mraa library to work with PWM and change the brightness level for the different LEDs and colors within an RGB LED. However, in the first chapter, we also installed the wiring-x86 library. We can change just a few lines of our object-oriented code to replace the mraa library with the wiring-x86 one to change the brightness levels for the red, green and blue components.

There is an important difference between the mraa library and the wiring-x86 library when working with PWM. The former works with floating point values from 0.0f to 1.0f to set the output duty cycle percentage, but the latter works with values from 0 to 255 inclusive to set this value. Thus, when working with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required