Help with dimming an LED

Hi,

I’m new to the beaglebone black, and have been getting started with writing my first programs, such as blinking LED’s, and simple control of the IO pins. I’m having trouble with a program I’m working on, in which you vary the voltage coming out of the PWM pins to change the color of an RGB LED. The project comes from this link https://learn.adafruit.com/fading-a-rgb-led-on-beaglebone-black/writing-a-program, and I’m having trouble converting the python code into JavaScript. My attempt at the JavaScript code is below:

`
var b = require(‘bonescript’);
var red = ‘P8_19’;
var blue = ‘P9_14’;
var green = ‘P8_13’;
var position = 0;
var interval = .05;

b.pinMode(green, b.OUTPUT);
fader();

b.pinMode(blue, b.OUTPUT);
fader();

b.pinMode(red, b.OUTPUT);
fader();

function fader() {
b.analogWrite(green, 1.0, 1000);
b.analogWrite(blue, 1-position, 1000);
b.analogWrite(red, position, 1000, scheduleNextColor);
}

function scheduleNextColor() {
position = position + interval;
if(position < 0) {
position = 0;
interval = -interval;
} else if(position > 1) {
position = 1;
interval = -interval;
}
setTimeout(fader, 500);
}
`

I am getting errors when I try to run the program:

error: error updating PWM freq and value: /sys/devices/ocp.3/bs_pwm_test_P8_19.60, Error: ENOENT, no such file or directory '/sys/devices/ocp.3/bs_pwm_test_P8_19.60/duty' error: error updating PWM freq and value: /sys/devices/ocp.3/bs_pwm_test_P9_14.59, Error: ENOENT, no such file or directory '/sys/devices/ocp.3/bs_pwm_test_P9_14.59/duty' error: error updating PWM freq and value: /sys/devices/ocp.3/bs_pwm_test_P8_19.60, Error: ENOENT, no such file or directory '/sys/devices/ocp.3/bs_pwm_test_P8_19.60/duty' error: error updating PWM freq and value: /sys/devices/ocp.3/bs_pwm_test_P9_14.59, Error: ENOENT, no such file or directory '/sys/devices/ocp.3/bs_pwm_test_P9_14.59/duty'

These errors will repeat, and sometimes the LED comes on, and sometimes it doesn’t. I am using the wiring diagram that is on the adafruit website, and I have a common anode LED. If you need more info, I can provide it. Any help is appreciated, thank you.