O'Reilly logo

Programming the BeagleBone by Yogesh Chavan

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

Writing on analog components

BoneScript provides the function analogWrite() to generate a PWM wave on any GPIO pin from the previous diagram. After a call to analogWrite(), the pin will generate PWM waves of a specified duty cycle. Here is the prototype of the analogWrite() function.

The code is as follows:

analogWrite(pin, value, [freq],[callback])

Where

pin – BeagleBone pin identifier string

value – duty cycle ratio of the PWM as value between 0 and 1

freq – frequency of PWM in Hz

callback – name of function which will be called automatically when analogWrite() finishes.

Here, freq and callback parameters are optional. If freq is not specified, the default value 2 kHz is used. The duty cycle ratio value is not taken as a percentage but as a ratio ...

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