Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paulvarache/node-gpio
https://github.com/paulvarache/node-gpio
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/paulvarache/node-gpio
- Owner: paulvarache
- Created: 2014-10-01T16:31:51.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-08-18T23:57:29.000Z (over 7 years ago)
- Last Synced: 2024-10-13T13:39:05.544Z (2 months ago)
- Language: C++
- Size: 17.6 KB
- Stars: 17
- Watchers: 6
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Node GPIO
==============A GPIO module for single board computers like the Raspberry Pi or the Banana Pi written in C++.
--------------Based on the sysfs, this module provides:
- Simple GPIO
- PWM
- Capacitive touchThe capacitive touch object uses two pins. One for charging the capacitor and the second to get the value.
Check out the example, they are quite self explanatory.
GPIO
*Light a led*```javaScript
var gpio = require('node-gpio');
var GPIO = gpio.GPIO;var led = new GPIO("28");
led.open();
led.setMode(gpio.OUT);
led.write(gpio.HIGH);
```
*Wait for a button push*
```javaScript
var gpio = require('node-gpio');
var GPIO = gpio.GPIO;var button = new GPIO("28");
button.open();
button.setMode(gpio.IN);
button.on("changed", function (value) {
console.log(value);
});
button.listen();
```PWM
*Lightly light a led*```javaScript
var gpio = require('node-gpio');
var PWM = gpio.PWM;var led = new PWM("28");
led.open();
led.frequency = 100;
led.dutyCycle = 50;
led.start();
led.stop();
```CapacityTouch
*Display all events on a capacitive touch device*```javaScript
var gpio = require('node-gpio');
var CapacityTouch = gpio.CapacityTouch;var touch = new CapacityTouch("24", "28");
touch.open();
touch.on("changed", function (data) {
console.log("Value: " + data.value);
console.log("Charge time: " + data.charge);
});
touch.listen();
```Every GPIO can be closed with:
```javaScript
pin.close();
```An event listening can be stoped with:
```javaScript
pin.stopListening();
```Do whatever you want with this module, I don't care.