1.0.1 • Published 7 years ago

oogpio v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

IN DEVELOPMENT, USE AT YOUR OWN RISK, NO PIN VALIDATION

Prequisites

  • nodejs and npm

Install

  • npm i oogpio

API THIS API IS UNDER DEVELOPMENT

To instantiate oogpio

var gpio = require('oogpio'); The first thing you want to do before writing or reading a pin is to set it up.

gpio.setup(pin_number, direction (gpio.IN or gpio.OUT), callback(error, data)); To write to a pin, you must set it up first (see example above) and then write to the pin

gpio.write(pin_number, value (1-on or 0-off), callback(error, data)); To read a pin, you must set it up first (see example above) and then read the pin

gpio.read(pin_number, callback(error, data)); To export a pin

gpio.export(pin_number, callback(error, data)); To unexport a pin

gpio.unexport(pin_number, callback(error, data)) To check if a pin has been exported

gpio.exported(pin_number); To get the direction of the pin

gpio.direction.get(pin_number, callback(error, data)); To set the direction of the pin

gpio.direction.set(pin_number, callback(error, data)); To get the list of exported (in and out) pins

gpio.list();

Examples

Setting up and writing to a pin. When writing you can send a 1 for on and a 0 for off var gpio = require('oogpio'); var pin = 12;

gpio.setup(pin, gpio.OUT, function(error, data){;

    if(error)
        return console.error(error);

    gpio.write(pin, gpio.HIGH, function(error, data){

        console.log(error || data);

    });

});

Setting up and reading a pin var gpio = require('oogpio'); var pin = 12;

gpio.setup(pin, gpio.IN, function(error, data){;

    if(error)
        return console.error(error);

    gpio.read(pin, function(error, data){

        console.log(error || data);

   });

});
1.0.1

7 years ago

1.0.0

7 years ago