forked from MarcoPPino/pandora-switches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduino-test.js
47 lines (42 loc) · 1.09 KB
/
arduino-test.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
36
37
38
39
40
41
42
43
44
45
46
47
const Readable = require("stream").Readable;
const util = require("util");
util.inherits(MyStream, Readable);
function MyStream(opt) {
Readable.call(this, opt);
}
MyStream.prototype._read = function() {};
// hook in our stream
process.__defineGetter__("stdin", function() {
if (process.__stdin) return process.__stdin;
process.__stdin = new MyStream();
return process.__stdin;
});
// then Johnny-Five code goes below here
const five = require('johnny-five');
const board = new five.Board({
repl: false
});
board.on("ready", function() {
// create buttons
const buttons = [];
const $panels = $('.switch');
for (var i = 0; i < 9; i++) {
// const button = new five.Button({
// pin: i+2,
// isPullup: true
// })
// button.index = i;
// button.on('press', function(){
// $panels.eq(this.index).addClass('active');
// });
// button.on('release', function(){
// $panels.eq(this.index).removeClass('active');
// });
}
const switchy = new five.Pin({
isPullup: true
});
switchy.read(function(err, val){
console.log(val)
})
});