-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
33 lines (28 loc) · 853 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
var Readable = require('stream').Readable
var util = require('util')
var five = require('johnny-five')
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
})
var board = new five.Board()
board.on('ready', function() {
document.getElementById('board-status').src = 'icons/ready.png'
var led = new five.Led(12)
var spdt = new five.Switch(9)
spdt.on('open', function() {
led.off()
document.getElementById('led-status').src = 'icons/led-off.png'
})
spdt.on('close', function() {
led.on()
document.getElementById('led-status').src = 'icons/led-on.png'
})
})