Arduino Blink Program With Node.js

Step 1 - Install Node.js

Installation Overview (Node.js)

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

Installation Steps

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

    Installation

Installation Overview (Jonny-Five)

  • Open Command Prompt.
  • Write the following command

    npm install johnny-five 

  • Wait for the installation.
Now, copy the code and save it into a .js file.
  1. var five = require("johnny-five");  
  2. var board = new five.Board();  
  3. // The board's pins will not be accessible until   
  4. // the board has reported that it is ready   
  5. board.on("ready"function() {  
  6.     console.log("Ready!");  
  7.     var led = new five.Led(13);  
  8.     led.blink(500);  
  9. });  
Step 2 - Setup Hardware

Hardware

Plug the Arduino and open the command prompt.

First, you need to specify the folder.
  1. node blink.js //your file name   
Done.

Now, you can blink your Arduino LED using Node.js.
Ebook Download
View all
Learn
View all