LCD I2C Firmata, johnny-five and NodeJS

This tutorial will show you how directly control Arduino via Firmata, NodeJS (as a server) and library johnny-five.
Step 1: load Firmata into Arduino Uno

Examples –> Firmata –> StandardFirmate –> Upload

Step 2: create a folder johnny_i2c on your desktop (you have to install NodeJS first)

cmd –> change directory to folder johnny_i2c

npm init –> Enter all and type yes at the last row

npm install johnny-five

create a file name index.js in the folder johnny_i2c with content

index.js


var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {


 var random = Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 4).toUpperCase();


 // Controller: PCF8574A (Generic I2C)
 // Locate the controller chip model number on the chip itself.
 var l = new five.LCD({
 controller: "PCF8574A"
 });
 
 l.clear();
 l.useChar("heart"); // use symbol of heart
 l.cursor(0, 0).print("hello world I2C");
 l.cursor(1, 0).print("use PCF8574A :heart:");
 l.cursor(1, 16).blink(); // hide the cursor

// no need to Ctrl+C
 setTimeout(function() {
 process.exit(0);
 }, 3000);
});

Step 3: run program (Command Prompt) node index.js

 

PS:

Use controller PCF8574A. Cannot use controller PCF8574

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s