node-wiringpi
v0.0.1
Published
Node bindings for libwiringPi
Downloads
4
Readme
node-wiringpi
Extremely simple node wrapper for @drogon's wiringPi library (for blinky lights & gpio w/ RaspberryPi)
Caution
This package assumes you know how to safely handle electronics and program GPIO pins. It's concievable you could damage yourself or your Raspberry Pi with improper circuit design or improper use of software interfaces. While the author of this package has made reasonable efforts to insure the accuracy of the information and code contained within, it comes with absolutely no warranty or guarantee of correctness.
Pre-Requisites
Before installing and/or building this package, please make sure you have the wiringPi library and the node-gyp package installed. WiringPi info can be found at https://projects.drogon.net/raspberry-pi/wiringpi/. Node-Gyp info can be found at https://github.com/TooTallNate/node-gyp.
Installation
The easiest way to install this package is via npm:
Or, you can check out the source using git:
Building
If the package wasn't automagically built when you installed via npm, this command should do the trick:
You'll have problems if you haven't installed node-gyp or libwiringPi.
Testing
I wrote a very simple LED blinker (this assumes you have a RPi w/ LEDs attached to GPIO pins. To run the program, use the command:
You have to run the program as root so it has permission to access /dev/mem. You could modify the permissions on this file, but please don't do that unless you understand how big of a security hole you're creating.
API
We currently only support two wiringPi calls: pinMode() and digitalWrite(). Hopefully the only thing you wanted to do was to write to the GPIO ports.
Start off by requiring the package:
If you're curious, you can call the num_pins() function to find out how many GPIO pins you have:
Before you write to GPIO lines, you should set them in output mode. This snippit sets pins 0 and 1 into output mode:
Once in output mode, you can write HIGH or LOW values to the pin. This sequence turns pins 0 and 1 on and off: