Fork me on GitHub
beagleboard.org

Demos

You might be able to see a newer version of this on beagleboard.org/support/bonescript/analogWrite

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

Output a pulse width modulated signal on pin. Valid pins are highlighted in yellow with "PWM" in their names (timers not yet supported):

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
  • callback: called upon completion

Return value

callback(x)

  • x.err: error status message

Example

var b = require('bonescript');
b.pinMode('P9_14', b.OUTPUT);
b.analogWrite('P9_14', 0.7, 2000.0, printStatus);
function printStatus(x) {
    console.log('x.err = ' + x.err);
}

Build and execute instructions

See also

Topics

Related functions

Examples