The JavaScript blog.


node modules arduino robots nodecopter

Getting Started with Nodebots

Posted on .

Hey, laser lips, your mama was a snow blower The johnny-five module, with art by Mike Sgier.

I've been collecting lots of resources relating to Arduino, Node, and robots, and there seems to be a lot of interest in the Node community around Arduino and quadcopters. The jewel in the crown of electronics-related Node modules is johnny-five (GitHub: rwldrn / johnny-five, License: MIT, npm: johnny-five. This Arduino programming framework from Bocoup provides an event-based interface into Arduino boards. The readme includes links to a wealth of examples written using JavaScript, embedded in Markdown with documentation and images. For example, Nodebot is a simple robot with motors and wheels that starts a REPL that allows you to move the robot around with commands like n.left.

Arduino works by accepting code over USB -- it comes with an IDE derived from Processing which does all of that for you. In johnny-five projects, the serialport module by Chris Williams (voodootikigod) makes getting code onto your electronic creations possible. Chris has been involved with the world of Node and Arduino since 2010. The serialport module requires native compilation -- the readme has instructions for Windows, OS X, and Linux.

Imagine a world where you can write JavaScript to control blenders, lights, security systems, or even robots. Yes, I said robots. That world is here and now with node-serialport. It provides a very simple interface to the low level serial port code necessary to program Arduino chipsets, X10 wireless communications, or even the rising Z-Wave and Zigbee standards. The physical world is your oyster with this goodie.

The API is event-based, so if you're familiar with Node's asynchronous core modules then you should be able to learn it pretty quickly. There are alternatives to johnny-five as well: duino by Cam Pedersen seems fairly mature.


The nodecopter-remote module can be used to script flying drones. It's built with johnny-five, and is popular with attendees of the NodeCopter.js events:

NodeCopter.js is a full day event where 15 - 60 developers team up in groups of 3.

Each team receives one Parrot AR Drone 2.0 and spends the day programming and playing with it. At the end of the day, each team gets to present their work to the other attendees.

I was introduced to NodeCopter.js by Andrew Nesbitt, who has spoken about Node and quadcopters at events in the UK, and organised Nodecopter London back in March.

There are a lot of other related modules on npm categorised under nodecopter -- one particularly fascinating one is voxel-drone which is an AR Drone simulator in voxeljs.com.

Getting Hardware

There are a lot of cheap Arduino kits around now. The johnny-five documentation mentions the SparkFun Inventor's Kit which is no longer available, but can be found in certain stores (I got one from Amazon a few months ago). The page for the kit has a list of the included parts, so you could order the ones you want separately.

All you really need is an Arduino board, but the important thing is the microcontroller -- you can use other boards with the same or compatible microcontrollers. Even better: Arduino is open, so you can build your own boards.

If you're not sure about Arduino but have access to a Raspberry Pi or BeagleBone, then you could try bonescript:

Bonescript is a node.js library for physical computing on embedded Linux, starting with support for BeagleBone.

The Raspberry Pi is more like a full-blown PC, but it has a simple hardware interface that does digital and analogue I/O -- meaning you can connect it to sensors and motors. I managed to wire mine up to an IR sensor from a defunct laptop to make Raspbmc work with my TV remote.

If you're hooking up hardware with Node, let me know in the comments and I'll check out your projects!


templating node logging modules podcasts documentation arduino

Node Roundup: 0.6.5, NodeUp, Logme, Consolidate.js, mdoc, Firmata, Nodeflakes

Posted on .

You can send your Node modules and articles in for review through our [contact form](/contact.html) or [@dailyjs](http://twitter.com/dailyjs).

Node 0.6.5

Node 0.6.5 is out, which upgrades V8 to and potentially avoids national
firewall-related issues.


NodeUp is a podcast all about Node. In NodeUp Nine features Isaac Z. Schlueter, Matt Ranney,
Dominic Tarr, and James Halliday discussing scaling, deployment, and
Erlang. Other topics include migrating to Node 0.6 and hosting on Joyent
with Solaris.

Subscribe with either iTunes or RSS:


Logme (License: MIT, npm: logme) by Veselin Todorov is a slick little logging library. Basic usage looks
like this:

var logme = require('logme');

It has a lot of colour themes, which are set by instantiating a
Logme object:

var Logme = require('logme').Logme;
  , logme = new Logme({ theme: 'smile' });

logme.error('This is now themed.');

The only thing I miss is the ability to quickly append values with
spaces, like this: console.log('Value:', value);.

It's worth remembering that console also comes with
console.error, which will write to stderr.


Consolidate.js (License: MIT, npm: consolidate) by TJ Holowaychuk is a wrapper that gives template engines the same API. TJ's documentation mentions that
Express 3.x uses the signature (path[, locals], callback)
for template rendering, which is the same as Consolidate.js.

This library adds a thin layer that makes it easier to switch between
different template engines.


mdoc (License: MIT, npm: mdoc) by Miller Medeiros is a markdown-based documentation generator. It'll create HTML files for each markdown file in a directory, and a
table of contents.

One of the author's examples is unofficial Node mdoc-generated
He's only been working on it for a few weeks, yet the style of the
documentation it generates is readable and suits larger projects.

Some projects benefit handcrafted documentation rather than JSDoc-style
API documentation. Miller wrote a post about this topic called Inline
Documentation: Why I'm Ditching


Firmata (GitHub: jgautier / firmata, License: MIT, npm:
firmata) by Julian Gautier is a library for interacting with Arduino boards running the firmata protocol.

If you're a Node developer you may find this more appealing than typical
Arduino code:

var firmata = require('firmata')
  , board;

board = new firmata.Board('path to usb', function() {
  // Arduino is ready to communicate


Nick Payne sent in
Nodeflakes (GitHub: makeusabrew / nodeflakes), a Twitter Streaming API experiment that displays CSS3 unicode snowflakes
that display tweets. The architecture is actually multiprocess, using a
producer/consumer architecture. The client-side code is in

Despite appearing to be a holiday-themed gimmick, Nodeflakes is very
educational. The author has written a detailed blog post about the
project: Nodeflakes - real time tweet powered