loading
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.

http://nodejs.org/download/

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
v0.10.26

<p>Hi, I'm a newb to all of this and having an issue. I'm on mac and using MAMP to upload to my localhost. I managed to get all the steps working until Step 6. In my console on my localhost I get 'Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8888/socket.io/socket.io.js' as well as 'ReferenceError: Can't find variable: io'. My Arduino has the LED on but none of the HTML controls do anything to change it. When trying to run 'node webtest.js' in terminal when in the MAMP localhost folder, I also get a ' events.js:141 throw er; // Unhandled 'error' event' appear. If anyone can help at all it would be very appreciated! </p>
<p>Hi I am looking for a forum to discuss the johnny five module. Do you have any good suggestions of online communities?</p>
<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>You would have to wright a function that does that.</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>You cannot access localhots via another computer. localhost always* refer the curent computer. If you want to access one computer via another, you'll have to find it's IP address and use it instead of localhost. If you localhost computer IP is 192.168.1.100, then on the other computer you should use http://192.168.1.100 instead of http://localhost.</p><p>*Not always, but if it's not the case, your either a ninja in networking, or should call tech support.</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>&quot;How do you run node.js scripts without the use of the web interface?&quot;</p><p>You have to run it via terminal `node scriptToRun.js`</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>On your computer. Node.js execute the code.</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>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>thanks! https://www.youtube.com/watch?v=ps-6U2mv5JY</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

55,662 views

109 favorites

License:

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: