-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
35 lines (26 loc) · 915 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var net = require('net');
var five = require('johnny-five');
var mock = require('mock-require');
mock('@serialport/bindings', '@serialport/binding-mock'); //Elegant way to disable hardware SerialPort that is not available in Termux
var firmata = require('firmata'); //Firmata implementation for Johnny-Five
var options = {
host: 'localhost', //host name or IP address
port: 8000 //some port
}
var client = net.connect(options, function() {
console.log('Connected to the server!');
var socketClient = this;
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('Board connected!');
//Full Johnny-Five code here:
var led = new five.Led(13);
led.blink();
//End of user code
});
});
});