node-gpio

0.1.1 • Public • Published

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 touch

The 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

    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

    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

    var gpio = require('node-gpio');
    var PWM = gpio.PWM;
 
    var led = new PWM("28");
    led.open();
    led.setMode(gpio.OUT);
    led.frequency = 100;
    led.dutyCycle = 50;
    led.start();
    led.stop();

CapacityTouch Display all events on a capacitive touch device

    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:

    pin.close();

An event listening can be stoped with:

    pin.stopListening();

Do whatever you want with this module, I don't care.

Readme

Keywords

none

Package Sidebar

Install

npm i node-gpio

Weekly Downloads

0

Version

0.1.1

License

ISC

Last publish

Collaborators

  • paulvarache