Getting Started with Nodebots

25 Jul 2013 | By Alex Young | Tags node modules robots nodecopter arduino
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.

NodeCopter

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!


blog comments powered by Disqus