-
-
Save mwittig/ea287e3ec818750753ac to your computer and use it in GitHub Desktop.
Remote Firmata Client over TCP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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