Git Product home page Git Product logo

node-cubieboard-gpio's Introduction

#Introduce

Use node.js to control gpio on cubieboard

#Install

npm install node-cubieboard-gpio

#Usage

  // Require library
  var GPIO = require('node-cubieboard-gpio');

  // initialize the gpio pin
  var pin = GPIO.PD0;
  var status = 0;
  GPIO.init();

  // config the gpio pin -> either input or output
  GPIO.setcfg(pin, GPIO.OUT);

  // toggle a pin on and off
  var toggle = function(){
    if(status){
      GPIO.output(pin, GPIO.LOW);
      status = 0;
    } else {
      GPIO.output(pin, GPIO.HIGH);
      status = 1;
    }
  }

  setInterval(toggle, 1000);

#Methods

  /**
    initializes a pin to be used as a gpio
    args: none
  **/
  GPIO.init()

  /**
    reads a pins input
    args: Pin - pin instance that will become the input
  **/
  GPIO.input()

  /**
    writes a pin output
    args: Pin - pin instance that will become the input
          State - pin state. Either GPIO.LOW or GPIO.HIGH
  **/
  GPIO.output()
  
  /**
  sets the configuration of the pin as an input or an output
  args: Pin - pin instance that will become the input
        Direction - direction of the pin. Either GPIO.OUT or GPIO.IN
  **/
  GPIO.setcfg()
  
  /**
  gets the configuration parameters of the pin
  args: none
  **/
  GPIO.getcfg()

node-cubieboard-gpio's People

Contributors

nlintz avatar youyudehexie avatar

Watchers

James Cloos avatar Sam Krew avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.