PLEASE NOTE: This article is obsolete or related to a discontinued product.

The FoxNode server-side API

FoxNode aims at simplifying access to your hardware resources from within NodeJS. The library innermost part is acme.gpio, a thin wrapper around the Linux kernel GPIO sys interface. A C helper program for dispatching user space interrupts to NodeJS is also included: your code can react immediately to state changes, without wasting CPU cycles in querying the hardware.

The higher level acme.daisy interface builds on these facilities to offer a simple programmatic access to Daisy devices. For now, only Daisy5 and Daisy11 are implemented, but support for more peripherals is planned.

The API for GPIO

First step, create a new GPIO pin object:

var acme = require('acme'),
    pin  = new acme.gpio.GPIO(name,direction,value);


  • name is any of the Fox/Daisy connectors, i.e. 'J6.1', 'J7.1', 'D1.1', ..., 'D8.8', or a kernel id number
  • direction is one of 'in' or 'out'
  • value can be 0 or 1

Direction and value can be read and changed after initialization with the following methods:

pin.direction()           # get
pin.direction(direction)  # set

pin.value()               # get
pin.value(value)          # set

Upon creation, the pin initializes the underlying hardware in order to react to state changes via interrupts. NodeJS is informed of such changes using a 'data' event, that can be used like this:

    'Pin:   ' +', '+
    'Value: '+data.value+', '+
    'Count: '+data.count

There is also a read-only property pin.count representing the number of value changes since pin instantiation.

It is possible to stop the event generation with


and to restart it afterwards with


The API for Daisy5

In order to instantiate a new Daisy5, the code is

var acme = require('acme'),
    daisy5 = new acme.daisy.Daisy5(port);

where port is one of 'D2' or 'D5'.

Daisy5 is configured as 8 input pins, readable as


and also as


where btn is one of 'P1' ... 'P8'.

Whenever one of the buttons changes state, the object will emit a 'data' event:

    'Port:   '+data.port+', '+
    'Button: '+data.button+', '+
    'Value:  '+data.value+', '+
    'Count:  '+data.count

The API for Daisy11

In order to instantiate a new Daisy11, the code is

var acme = require('acme'),
    daisy11 = new acme.daisy.Daisy11(port);

where port is one of 'D2' or 'D5'.

Daisy11 is configured as 8 output pins, readable and writable as


and also as


where led is one of 'L1' ... 'L8'.

Whenever one of the leds changes state, the object will emit a 'data' event:

    'Port:  '+data.port+', '+
    'Led:   '+data.led+', '+
    'Value: '+data.value+', '+
    'Count: '+data.count