Skip to content

Instantly share code, notes, and snippets.

@mwittig
Forked from monteslu/remoteClient.js
Created December 6, 2015 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwittig/ea287e3ec818750753ac to your computer and use it in GitHub Desktop.
Save mwittig/ea287e3ec818750753ac to your computer and use it in GitHub Desktop.
Remote Firmata Client over TCP
var net = require('net');
var five = require('johnny-five');
var firmata = require('firmata');
var options = {
host: '192.168.2.5', //whatever host
port: 48879 //some port
};
var client = net.connect(options, function() { //'connect' listener
console.log('connected to server!');
var socketClient = this;
//we can use the socketClient instead of a serial port as our transport
var io = new firmata.Board(socketClient);
io.once('ready', function(){
console.log('io ready');
io.isReady = true;
var board = new five.Board({io: io, repl: true});
board.on('ready', function(){
console.log('five ready');
//Full Johnny-Five support here:
var led = new five.Led(7);
led.blink();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment