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 400,000 packages pre-installed, including ioboard with all npm packages installed. Try it out:

var ioboard = require("ioboard")

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

ioboard v3.0.0

Provides a standard interface to boards capable of IO (e.g. Arduinos, Maestros, Raspberry Pis, etc) and their firmware

ioboard

An extendable implementation of Johnny Five's IO Plugins.

Implements all required and optional methods, along with the required constants - MODE, HIGH, LOW, etc.

You should configure the relevant pins of your board in your constructor, then emit the ready event.

E.g.:

var util = require('util'),
  IOBoard = require('ioboard');

MyIO = function(path, callback) {
  // call super constructor
  IOBoard.call(this);

  // connect to hardware and emit "connected" event
  this.emit("connected");

  // .. configure pins
  this._pins.push(..);

  // all done, emit ready event
  this.emit("ready");

  // finally call the passed callback
  callback();
}
util.inherits(IO, IOBoard);

Finally implement any of the IO Plugin methods of your choosing:

// implement digitalWrite
MyIO.prototype.digitalWrite = function(pin, value) {
  ..
};

Logging

By default IOBoard will print a message when every non-implemented method is invoked. To prevent this, set the quiet property of the super constructor args to true:

MyIO = function(path, callback) {
  // call super constructor
  IOBoard.call(this, {
    ..
    quiet: true
  });

  ..
}
util.inherits(IO, IOBoard);

Metadata

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