gpiojs

Raspberry Pi GPIO module for node.js

npm install gpiojs
1 downloads in the last day
2 downloads in the last week
11 downloads in the last month

GPIO.js - For now, a simple wrapper

This is a stupid module for controlling the GPIO ports on the Raspberry Pi. It just spawns a new new process in order to communicate with gpio. I'll eventually make a c module that will do better. I couldn't get the other node modules to work, so I made this simple wrapper. Sorry it is so dumb.

Requires wiringpi

npm install gpiojs

Note: Since this requires wiringpi, if you use this, please follow wiringpi's gpio scheme

API

To use, include:

var gpio = require('gpiojs');

gpio.set( port, value, callback )

Sets a GPIO port value. Example:

gpio.set( 1, 1, function(){
  console.log("Set port 1 to high");
});

gpio.label( name, port )

Alias a GPIO ports

gpio.label( 'led-1', 1 );
gpio.set( 'led-1', 1, function(){
  console.log("Led-1 is now on");
});

gpio.setMode( port, mode, callback )

Sets a GPIO port mode. If you want to send a signal out, then set your port to out. Example:

gpio.setMode( 1, 'out', function(){
  console.log("Port 1 ready for writing");
});

gpio.readAll( callback )

Get the current GPIO configuration. Equivalent to gpio readall. Sends an array of objects to the second argument of the callback. The index of the array corresponds to the GPIO port. Example:

gpio.readAll( function( error, config ){
  console.log( "GPIO Port 1 has mode of", config[ 1 ].Mode, "and value of", config[ 1 ].Value );
});
npm loves you