Use your JavaScript and web development knowledge to control Arduino projects and even robots (node + robots = nodebots)!

This is made easy with node.js, Firmata and Johnny-Five. Let's get started!

Johnny-Five logo by Mike Sgier. Arduino photo CC-BY Raeky.

Step 1: Install node.js

Node.js is a javascript runtime based on Chrome's V8 engine. If you haven't used it before, node lets you run Javascript code on the server-side, it's designed around non-blocking I/O and asynchronous events. Node includes modules for accessing the filesystem, a web server, sockets and other basic tasks.

Download and install the node for your platform. Source and binaries are available for Windows, OS X and Linux.


If you're using Ubuntu/Debian, you can use apt-get install nodejs (not node). If you're using a distro's package manager, make sure your node version is recent!

node --version

<p>Awesome! , thanks for the tutorial, but:</p><p>i dont have any servos, so the web page doesn't do anything to my arduino; how can i turn on and off different leds depending on which button i press?</p><p>I couldn't figure out how to do it</p>
<p>Great tutorial!</p><p>I'm having a little trouble when I get to the websockets section. When I run 'node webtest.j's' I receive an error message stating &quot;TypeError object Serialport has no method 'write'&quot;</p><p>Any ideas on what I'm doing wrong?</p>
<p>Try installing without npm;</p><p>git clone git://github.com/rwaldron/johnny-five.git &amp;&amp; cd johnny-five</p><p><br><br>npm install</p>
Nice project. Is there a way to use this with esp8266? Here is the plot: start an ACcess point and webserver on esp8266 programmed using arduino ide. Run code on esp8266 that can intercept data from a smartphohe running webapp that communicates via websocket. Is this possible?
<p>excellent!!! :)</p>
<p>This may be obvious to some, but where does the JavaScript code execute? Is it on the computer or the Arduino?</p>
<p>Thank you! I hooked up a simple force sensor to an Arduino and managed to browse Google Maps with it!</p><p><br><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/pMmQyJ3je9k" width="500"></iframe><br></p>
<p>Well done, very cool :D</p>
<p>Instead of an arduino, could an launchpad msp430 be used?</p><p>I have the latest firmata running correctly (or so I think) on the launchpad, but I don't have any way of seeing if it speaks firmata to the pc. I'm new to node.js but I believe it installed correctly.. same with Johnny5. </p><p>Is there a sample script that will query the launchpad for the firmata version string? </p><p>Also, the instruction:</p><blockquote>If you'd like to create a web interface you'll need socket.io too:</blockquote><p>How do you run node.js scripts without the use of the web interface? I thought you execute a node.js script by opening a browser with the url : <a href="http://localhost:3000" rel="nofollow"> http://localhost:3000 </a> . Is there another way to run node.js? </p>
<p>thanks! https://www.youtube.com/watch?v=ps-6U2mv5JY</p>
<p>exelent port :D</p><p>i was trying to acces localhost from other computer on my network and i can look the page but dont allow me to make change, what can i do ?</p>
<p>I cannot get it to work when I specify a board like so:</p><p>board = new five.Board({ port: &quot;/dev/tty.usbmodem1431&rdquo;});</p><p>My Terminal says:</p><p>/path/to/file/but/this/isn't/it/ledtest.js:3</p><p>board = new five.Board({ port: &quot;/dev/tty.usbmodem1431&rdquo;});</p><p> ^^^^^^^^^^^^^^^^^^^^^^^^^^</p><p>SyntaxError: Unexpected token ILLEGAL</p><p> at Module._compile (module.js:439:25)</p><p> at Object.Module._extensions..js (module.js:474:10)</p><p> at Module.load (module.js:356:32)</p><p> at Function.Module._load (module.js:312:12)</p><p> at Function.Module.runMain (module.js:497:10)</p><p> at startup (node.js:119:16)</p><p> at node.js:906:3</p>
<p>Hello, check your trailing quotation mark, it's curly, I think that may be tripping things up!</p><p>board = new five.Board({ port: &quot;/dev/tty.usbmodem1431&quot;});</p>

About This Instructable


100 favorites


Bio: Sharing knowledge and ideas. Constantly learning!
More by danasf: Intel Edison and Addressable LEDs Internet of Ducks Lighting In A Bottle
Add instructable to: