Skip to content

Instantly share code, notes, and snippets.

@andrewn
Created March 7, 2014 14:02
Show Gist options
  • Save andrewn/9412037 to your computer and use it in GitHub Desktop.
Save andrewn/9412037 to your computer and use it in GitHub Desktop.
var wpi = require('./build/Release/wiringPi');
wpi.wiringPiSetup();
var colour = [255, 255, 0];
var pins = [0, 2, 3 ];
pins.forEach(createPwmPin);
setColour(colour);
function setColour(colours) {
colours.forEach(setPwmPin);
}
function setPwmPin(colourValue, pinIndex) {
wpi.softPwmWrite(pins[pinIndex], colourValue);
}
function createPwmPin(pinNum) {
wpi.softPwmCreate(pinNum, 255, 255);
}
// The programme quits now because everything's been done
// but it needs to stay running otherwise the lights go
// out. :-(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment