Tuesday, February 02, 2016

Using JS on Arduino (Part 1)

Using Javascript to control an arduino seems far fetched but there is this great library call Johnny Five which allows you to control an arduino (or many other boards see http://johnny-five.io/platform-support .

In this article we will go over how to set up using your Arduino with javascript.

The first step should be loading the Arduino application on your computer and running the blink app. This is the "Hello World" for Arduinos and should tell you if your micro controller is working.  See the picture to find where it is.
After running the blink sketch then install Node version 4.2.1 if you haven't already. You can find it here https://nodejs.org/en/blog/release/v4.2.1/ . Then install yeoman at by doing 
npm install -g yo and johnny-five generator by executing in a terminal 
npm install -g generator-johnny-five .  

Finally create the scaffolding to your project doing 
yo johnny-five
Then follow the generator and do node index.js
to test out if everything is working on the javascript side. A good resource for examples is the johnny-five website at http://johnny-five.io