Arduino Uno - Getting Started

Over the years, I have been into programming but I always wanted to work with hardware and somehow wanted to interact with it using my programming skills. I came across this Arduino and VoilĂ , I really liked working with it, thought to write articles on it and here I am to write my first blog post on Arduino Uno with JavaScript. Let's get started and jump right in with Hello World but in Electronics Style.

Prerequisite to get started with Arduino

1. To get started, you need to get this Arduino Uno board. Buy from wherever you want.

2. Install Node.js. Follow the steps here provided at this URL.

3. To program in JavaScript, you need Johny Five Library. Two ways to get that - either install it from its official site or use Node (installed above in 2nd step). Just open command prompt in Windows or Terminal in OSx and type the following command npm install johnny-five. It will install that for you.

4. Last thing to get started is Arduino Sketch. You can get this from here. This software is required just to set up the board once for Firmata. Firmata is a communication method between board and node using JavaScript.

Fun Part - Let's Start

Now you have everything setup. Open the Arduino Sketch and connect your board with your computer's USB port with the help of a USB cable that you must be having with your board. In Arduino Sketck, Goto File->Examples->Firmata->StandardFirmataPlus. This will open a standard firmata program for setting up your board for the communication. Click on upload icon in the sketch. That's it, now your board is ready to communicate via JavaScript.

Now we will do some physical stuff. We need to get one Led which you can buy from anywhere. Plug the Led into the board see the image below, your Led must be having two legs. Both with the different length shorter one is for ground and longer one for VCC +5. Plug shorter leg into GND and longer one into pin 13. Plug it like below image - 

Now create a JavaScript file and write the below program in the file -

var five = require("johnny-five");
var myBoard = new five.Board();
myBoard.on("ready", function() {
  myLed = new five.Led(13);
  myLed.strobe( 1000 );
    led: myLed

Save the file as helloWorld.js and open command prompt in Window or Terminal in OSx and type node helloWorld.js (make sure your board is still plugged in) and now when you run the program, Led shines like a star :P. This is pretty much to get started with Arduino. Stick with us for some more awesome article on Arduino Programing Using JavaScript.

Let us know if you have any query or concerns. Happy Reading.


Popular posts from this blog

Just Maths - Views, View Groups and Layouts

Create Android Apps - Getting Started