LED Blinking Program Using Node js and Arduino.

Node.js is a very powerful JavaScript-based framework built on Google Chrome’s JavaScript V8 Engine. It is used to develop I/O intensive web applications like video streaming sites, single-page applications, and other web applications. Node.js is open source, completely free, and used by thousands of developers around the world.

Node isn’t a program that you simply launch like Word or Photoshop: you won’t find it pinned to the taskbar or in your list of Apps. To use Node you must type command-line instructions, so you need to be comfortable with (or at least know how to start) a command-line tool like the Windows Command Prompt, PowerShell, Cygwin, or the Git shell (which is installed along with Github for Windows).

Components Required

  • 1 x Arduino Uno board
  • 1 x LED

Software Required

  • Johnny-Five  :- Johnny-Five is the JavaScript Robotics & IoT Platform. Released by Bocoup in 2012, Johnny-Five is maintained by a community of passionate software developers and hardware engineers. More than 75 developers have made contributions towards building a robust, extensible and compatible ecosystem. We will achieve this with the Johnny-Five library for Node.js to program our robot. Johnny-Five uses a protocol called Firmata to communicate with the micro-controller over the USB .

Step 1 – Setting up Firmata to Arduino Board

Before going to start programming with NodeBots, First we need to load Firmata onto Arduino board.

  • Download Arduino IDE from it’s official website
  • Connect Arduino board via USB cable
  • Launch Arduino IDE and find the Firmata sketch using the Menu -> File -> Examples -> Firmata -> StandardFirmata
  • Select your Arduino board type using Tools -> Board
  • Select the port (Comm Port) for the board using Tools -> Serial Port
  • Upload the “StandardFirmata” program by selecting File -> Upload

Step 2 – Node.js  Installation Overview

Installing Node and NPM is pretty straightforward using the installer package available from the Node.js® web site.

Step by step guide line

  • Download the Windows installer from the Nodes.js® web site.
  • Run the installer (the .msi file you downloaded in the previous step.)
  • Follow the prompts in the installer (Accept the license agreement, click the NEXT button a bunch of times and accept the default installation settings).

  • Restart your computer. You won’t be able to run Node.js® until you restart your computer.

Step 3 – Johnny-five Installation Overview

  • Open Command Prompt.
  • Run the following command in CMD
npm install johnny-five

  • Wait for installation complition.

Step 4 – Code Segment

  • Open editor (Notepad, Notepad++, Edit Plus) and write below program
var led_pin=13;
var johnny_five=require("johnny-five"); 
var arduino_board=new johnny_five.Board(); 
arduino_board.on("ready", function() {  
   console.log("Program is Ready!");  
   var led = new johnny_five.Led(led_pin);  
   led.blink(1000);  
});
  • Save program in computer.

Step 5 – Hardware Setup

Step 6 – Execution

  • Open command prompt
  • Specifies your saved file location by using cd command in command prompt
  • Run the following command
node your_file_name.js

  • Now you can see the output of your LED blinking using Arduino and Nodejs.
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp
Share on telegram
Share on reddit
Share on tumblr
Related Posts
About Author

Leave a Comment

Your email address will not be published. Required fields are marked *