wpi-gpio
v1.2.0
Published
Wrapper around the WiringPi gpio command-line utility
Downloads
23
Maintainers
Readme
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
.