npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ms-gpio

v3.1.0

Published

API for controlling Raspberry PI GPIO pins

Downloads

15

Readme

ms-gpio

Manage Raspberry Pi GPIO pins with node.js & Raspbian (Linux) OS

Setup

Raspbian OS must be preloaded/installed on Raspberry PI device. For installation refer this page

Latest version of node be installed on your Raspberry PI device, follow below steps to update node to latest version:

curl -sLS https://apt.adafruit.com/add | sudo bash
sudo apt-get install node

ms-gpio module can then be installed with npm:

npm install ms-gpio

Usage

In order to work with Raspberry PI GPIOs, node application must run under root access.

Prior to reading or writing a GPIO pin, setup operation/function must be invoked. After this, read and write operation on a pin can be performed.

GPIO pins can be accessed ; either using the Raspberry Pi physical numbering or with BCM/SoC naming scheme . This module supports Raspberry Pi(BOARD) pin scheme, that is board pin number must be passed. Please see this page for more details.

API

Methods

setup(pinNo, direction)

Sets up a pin for read or write. It must be done before the pin can be used for either reading or writing

  • pinNo : Reference to the GPIO pin
  • direction: Pin direction can be set to INPUT_MODE for read mode or OUTPUT_MODE for write mode. If not passed, it defaults to OUTPUT_MODE

read(pinNo)

Reads the value of a pin, returns boolean value true for high voltage (ON) & false for low voltage (OFF).

  • pinNo : Reference to the GPIO pin
  • error : Prior to the read operation, setup operation must be performed. Else error is thrown from the method

write(pinNo, value)

Writes the value of a pin.

  • pinNo : Reference to the GPIO pin
  • value : A boolean value of true for high voltage (ON) & false for low voltage (OFF) must be passed
  • error : Prior to the write operation, setup operation must be performed. Else error is thrown from the method

tearDown()

Unexports all the exported pins.

Examples

Setup and read the value of a pin

var gpio = require('ms-gpio');
gpio.setUp(16, gpio.INPUT_MODE);
gpio.read(16);

Setup and write to a pin

var gpio = require('ms-gpio');
gpio.setUp(16, gpio.OUTPUT_MODE);
gpio.write(16,true); //Sets the GPIO to high
gpio.write(16,false); //Sets the GPIO to low

Tear down the exported pin

var gpio = require('ms-gpio');
gpio.tearDown();