analogWrite(pin, value, [freq], [callback])
Output a pulse width modulated signal on pin.
The name 'analogWrite' comes from other open source libraries with recognition that a PWM tied to a low-pass filter will produce an analog voltage level. A PWM can also be used to control some types of motors. Read more about PWMs on the Wikipedia pulse-width modulation page .
Valid pins are highlighted in
yellow with "PWM" in their names (timers not yet supported):
Note: This function is currently incompatible with pinMode which may force the pin mux to GPIO mode only.
Arguments
- pin: the BeagleBone pin identifier
- value: duty cycle of the PWM as a value between 0 and 1
- freq: frequency of the PWM in Hz (default is 2kHz)
- callback: called upon completion
Return value
callback(x)
- x.err: error status message
Example
var b = require('bonescript'); b.analogWrite('P9_14', 0.7, 2000, printJSON); function printJSON(x) { console.log(JSON.stringify(x)); }
Build and execute instructions
See also
Topics
Related functions
Examples
Last updated by jkridner on Mon Aug 19 2013 20:05:59 GMT-0000 (UTC).