-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.js
51 lines (39 loc) · 876 Bytes
/
button.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
48
49
50
51
const five = require("johnny-five");
const { RaspiIO } = require("raspi-io");
const board = new five.Board({
io: new RaspiIO(),
});
// let pigpio = require("pigpio");
// pigpio.configureSocketPort(8889);
board.on("ready", () => {
// GPIO18 - Physical Pin P1-12 - Wiring Pi 1
const button = new five.Button({
pin: "P1-18",
isPullup: true,
});
const b2 = new five.Button({
pin: "P1-16",
isPullup: true
})
const led = new five.Led("P1-7");
button.on("down", () => {
console.log("down...");
led.toggle();
});
b2.on('down', () => {
console.log('b2 down...')
led.toggle()
})
// button.on("up", () => {
// console.log("up...");
// });
// button.on("hold", () => {
// console.log("hold...");
// });
board.on("exit", function () {
led.stop().off();
});
board.repl.inject({
led
});
});