-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
33 lines (28 loc) · 778 Bytes
/
app.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 five = require('johnny-five');
var raspi = require('raspi-io');
var exec = require('child_process').exec;
var cmd = 'shutdown -P now';
try {
var board = new five.Board({
io: new raspi(),
repl: false,
debug: false
});
} catch (err) {
console.log('Error: ' + err);
};
try {
board.on('ready', function() {
// Create a new "button" hardware instance with onlut on pin 7.
button = new five.Button(7);
// "down" the button is pressed
button.on("down", function() {
// console.log('Button pressed');
exec(cmd, function(error, stdout, stderr) {
// command output is in stdout
});
});
});
} catch (err) {
console.log('Error: ' + err);
};