Update This article is translated to Serbo-Croatian by Jovana Milutinovich.
Today is Tuesday, May 15th 2012. Just over a year ago, I discovered node-serialport by Chris Williams and went immediately to the closest Microcenter and purchased the Getting Started with Arduino kit.
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.
About a month later at JSConf 2011 in Porland Oregon, while sitting on the floor in the hallway, Max Ogden and I hacked together a rad demo that allowed him to slide his finger back and forth over a Soft Potentiometer Membrane to control video playback. The sensor was attached to an Arduino board, the board then connected via USB to his laptop, which was running a Node.js program that listened for serialport data events and pushed the sensor data back out to a web browser client via Socket.IO, which was processed into time and handed off to Popcorn.js.
Soft Pot > Arduino > USB > Node Serialport > Socket.IO > Popcorn.js
Once the touch data reached the client on the browser, which was being displayed on my laptop, we used Popcorn.js and the data values to fast-forward and rewind a video of a Monkey Riding a Dog. That code is available here and you can watch the demo here (jump to 22:34).
Then this happened…
And everything changed.
Board constructor that, while inspired by and conceptually similar to Cam’s
duino.Board(), had finer abstractions for instance management, active serial/USB discovery and by-default REPL sessions built in to every program. This is the foundation of Johnny-Five.
Once I had the initial
Board constructor, I created a slightly modified version of Julian’s servo-sweep.js as a proof of concept for baseline of the framework:
With a stronger
Board constructor, porting all of the modules I had created for Duino into this new framework was mostly a breeze. A few days later, the
Servo module emerged, transforming the code into this:
Over the next few weeks as I acquired new hardware and sensors, each new piece brought with it a new physical engineering and software engineering challenge. Several times I found myself revisiting a stable module and starting over when a useful abstraction presented itself. One of the most important refactorings that occurred had nothing to do with code. Early on it became clear that I would need to document the hardware that I was building, especially if I was to continue creating sans permanence. Arduino tutorials are often published with colorful illustrations of the microcontroller connected to a breadboard and various gadgets - this is what I wanted and what I found in Fritzing. With Fritzing, I now had the tools to quickly and easily create detailed, visually appealing documentation of the hardware that accompanied each of the example programs that I created.
Once assembled, the program can be run from the command line as
and should look like this:
Admittedly, this example is less-then-mind-blowing — but it’s just one piece of a larger whole.
As part of Johnny-Five’s development process, I’ve created 28 component-centric mini-programs. I intend to publish these along with breadboard schematics and parts lists, twice each week over the next few months.