Bonescript : AnalogWrite error

Here I am trying to turn on a buzzer for one second and then turn it off. Here is the code

#!/usr/bin/env node
var b = require(‘bonescript’);

b.pinMode(‘P8_19’, b.ANALOG_OUTPUT);

b.analogWrite(‘P8_19’, 0.5, 2000.0, printStatus);

function printStatus(x) {
console.log('x.value = ’ + x.value);
console.log('x.err = ’ + x.err);

setTimeout(function() {
b.analogWrite(‘P8_19’, b.low); // Turn off buzzer after milliseconds time
}, 1000);

This code gives the following error after i try to run it immediately after reboot
error: Error enabling PWM controls: Error: ENOENT, no such file or directory '/sys/devices/ocp.3/bs_pwm_


how to solve the problem?

Have you loaded the PWM overlay ?

One more tidbit

*/Note:/ This function is currently incompatible with pinMode which may
force the pin mux to GPIO mode only. *

In which case. Unless you need something around 1-2Khz( at most ), Nodejs wont cut it.

how to load the PWM overlay?

william, I have tried with 1.5khz still the problem is same.