1.2.0 • Published 8 years ago

wpi-gpio v1.2.0

Weekly downloads
8
License
MIT
Repository
github
Last release
8 years ago

wpi-gpio

A no-frills wrapper around the WiringPi gpio command-line utility.

Installation

$ npm install wpi-gpio

Usage

var gpio = require('wpi-gpio');

Pin numbering

By default, wpi-gpio uses the WiringPi pin numbers. To use Broadcom GPIO (BCM) pin numbers instead (the -g flag to gpio):

gpio.BCM_GPIO = true;

Methods

gpio.input(1).then(function() {
  // GPIO pin 1 set as input pin
});
gpio.output(2, 0).then(function() {
  // GPIO pin 2 set as output pin with value 0 (default value is optional)
});
gpio.input(1).then(function() {
  gpio.pullUp(1).then(function() {
    // set as input with pull-up resistor
    // also available are `gpio.pullDown` and `gpio.triState`
  })
});
gpio.read(3).then(function(val) {
  // `val` is numeric value of GPIO pin 3
});
gpio.write(4, 1).then(function() {
  // GPIO pin 4 value set to 1
});
gpio.sequence(5, [0, 1, 0, 1]).then(function() {
  // GPIO pin 5 has values written in series, with a 100ms delay between values
});
gpio.tap(6).then(function() {
  // GPIO pin 6 is "tapped" once. Same as `gpio.sequence(6, [1, 0, 1])`
});

License

This software is released under the terms of the MIT license. See LICENSE.

1.2.0

8 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago