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

pcduino-iojs

v0.0.7

Published

A node.js module for accessing the Arduino compatible pins on the pcDuino microcontroller.

Downloads

5

Readme

node.pcduino

A node.js module for accessing the Arduino compatible pins on the pcDuino microcontroller. It tries to maintain as close a match as possible to the original Arduino C++ functions.

Installing Node.js runtime on the pcDuino

It turns out the easiest way to install the latest version of node.js on the pcDuino is to use the precompiled binaries for the Raspberry Pi as provided by the folks at nodejs.org. Here's how to install it on the pcDuino from the command line:

wget http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-arm-pi.tar.gz

tar xvzf node-v0.10.24-linux-arm-pi.tar.gz

cd node-v0.10.24-linux-arm-pi

# Remove some extra files that we don't need
rm ChangeLog LICENSE README.md

sudo cp -R * /usr/local

You can replace the version to install later versions (0.10.24 was the latest as of this writing), but it does appear that the Raspberry Pi binaries tend to lag behind the latest version on the Node.js website by a couple versions.

Installing the Node Package

From the command line:

npm install pcduino --save

Adding the --save switch will automatically add it to your package.json file.

A digital example

var pcduino = require("pcduino");
var digital = pcduino.digital;

// digital.simulate(true); - Can be used for testing purposes when you're not running on a pcDuino. This will read and write to dummy files.

console.log("There are " + digital.PIN_COUNT + " digital GPIO pins on the pcDuino.");


digital.pinMode(10, digital.INPUT); // Set pin #10 to input
digital.pinMode(10, digital.INPUT_PU); // Set pin #10 to input with pull-up


var state = digital.digitalRead(10);
console.log("The value of pin #10 is " + (state == digital.HIGH ? "HIGH" : "LOW"));


digital.pinMode(10, digital.OUTPUT);          // Set pin #10 to output


digital.digitalWrite(10, digital.HIGH);       // Set pin #10 HIGH

state = digital.digitalRead(10);
console.log("The value of pin #10 is now " + (state == digital.HIGH ? "HIGH" : "LOW"));


digital.digitalWrite(10, digital.LOW);        // Set pin #10 LOW

state = digital.digitalRead(10);
console.log("The value of pin #10 is now " + (state == digital.HIGH ? "HIGH" : "LOW"));

An analog example

var pcduino = require("pcduino");
var analog = pcduino.analog;

console.log("There are " + analog.PIN_COUNT + " analog pins on the pcDuino.");

// Note that the only valid pins for analog output are 3, 5, 6, 9, 10, and 11. These are PWM (digital) pins on the pcDuino and not to be confused with the analog input pins. Any other pin specified will throw an error.
var maxValue = analog.maxWriteValue(5);
console.log("The maximum number that can be written to analog pin #5 is " + maxValue);

analog.analogWrite(5, maxValue);            // Turn our pin fully up

// Note this is not the same as the analog write pin #5! This maps to the analog input pins on the pcDuino. Valid pins are 0, 1, 2, 3, 4, 5.
var readValue = analog.analogRead(5);
console.log("The analog value of pin #5 is " + readValue + ". Note this is not the same as the analog write pin #5!");

Limitations

The current version of this module uses the standard unix filesystem mappings to the GPIO pins which, while fast enough for most general purposes, are not fast enough to perform high-speed protocols (like 1-wire for example). There is a subdirectory called WIP, which is a start to some pure C++ native code access to the pins— although even it appears to be too slow and will probably require the use of interrupts or DMA at some point.