Skip to content
Arvydas Juskevicius edited this page Mar 31, 2016 · 10 revisions

Welcome to the BlinkStick for Node.js wiki!

Quick guide to blinkstick-node API

var blinkstick = require('blinkstick');

To get the first BlinkStick on your system:

var led = blinkstick.findFirst();

To get all the serial numbers for BlinkStick(s) on your system:

blinkstick.findAllSerials(function(serials) {
    console.log(serials);
});

To get all the BlinkStick(s) on your system:

var leds = blinkstick.findAll();

To get the serial number, manufacturer, or description associated with a BlinkStick:

led.getSerial(function(err, data) {
    console.log(data);
});

led.getManufacturer(function(err, data) {
    console.log(data);
});

led.getDescription(function(err, data) {
    console.log(data);
});

To set the color:

// rgb is a '#RRGGBB' string
// red/green/blue are each numbers in [0..255]
// function is optional

led.setColor(rgb, function() { /* called when color is changed */ });
led.setColor(red, green, blue, function() { /* called when color is changed */ });

led.setColor('random', function() { /* called when color is changed */ });

led.turnOff();    // i.e., setColor(0, 0, 0)

To set the color for BlinkStick Pro:

// All functions above work with additional options object

//Set random color for 4th LED on R channel 
led.setColor('random', { 'channel': 0, 'index': 4 }, function() { /* called when color is changed */ });

To get the color:

led.getColor(function(red, green, blue) { ... });
led.getColorString(function(rgb) { ... });

Blink, pulse and morph:

//All color parameters and options work on these functions too
led.pulse(rgb, function() { /* called when color animation is complete */ });
led.blink(rgb, function() { /* called when color animation is complete */ });
led.morph(rgb, function() { /* called when color animation is complete */ });

You can find full up to date API documentation here:

http://arvydas.github.io/blinkstick-node/

Running examples

Navigate the the example directory, install dependencies and run the server:

$> cd node_modules/blinkstick/examples/picker
$> npm install
$> node server

Then, in a browser, navigate to the url given in the console.

Other examples require simply running:

$> node node_modules/blinkstick/examples/[example_name]/[example.js]

Additional Examples

Development