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.
Installation
From the command line:
$ npm install pcduino
Or in your package.json file:
{
"dependencies" : {
"pcduino" : "*",
}
}
A digital example
var pcduino = ;var digital = pcduinodigital; // 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; digital; // Set pin #10 to inputdigital; // Set pin #10 to input with pull-up var state = digital;console; digital; // Set pin #10 to output digital; // Set pin #10 HIGH state = digital;console; digital; // Set pin #10 LOW state = digital;console;
An analog example
var pcduino = ;var analog = pcduinoanalog; console; // 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;console; analog; // 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;console;
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.