Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including pwm with all npm packages installed. Try it out:

var pwm = require("pwm")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pwm v0.0.3

Write to your PWM outputs

pwm - API to use PWM gpio through /sys

Derived from

Standard setup
var pwm = require("pwm");

// Calling export with a chip number and a pin number will export that
// header and return a pwm header instance
var pwm5 = pwm.export(0, 5, function() {
API Methods
// Enable pin
pwm5.setEnable(1, function() {
// Set pin period
pwm5.setPeriod(1000000, function() {
    console.log("Period set!");
// Set pin duty cycle
pwm5.setDutyCycle(500000, function() {
    console.log("Duty cycle set!");
// Reset
// unexport program when done


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free