UNPKG
onoff
Version:
latest (6.0.3)
6.0.3
6.0.2
6.0.1
6.0.0
5.0.1
5.0.0
4.1.4
4.1.3
4.1.2
4.1.1
4.1.0
4.0.0
3.2.9
3.2.8
3.2.7
3.2.6
3.2.5
3.2.4
3.2.3
3.2.2
3.2.1
3.2.0
3.1.0
3.0.2
3.0.1
3.0.0
2.0.0
1.2.0
1.1.9
1.1.8
1.1.7
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.3.2
0.3.1
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.0
0.0.1
GPIO access and interrupt detection with Node.js
github.com/fivdi/onoff
fivdi/onoff
onoff
/
examples
/
light-switch.js
20 lines
(14 loc)
•
295 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict'
;
const
Gpio
=
require
(
'../onoff'
).
Gpio
;
const
led =
new
Gpio
(
17
,
'out'
);
const
button =
new
Gpio
(
4
,
'in'
,
'both'
); button.
watch
(
(
err, value
) =>
{
if
(err) {
throw
err; } led.
writeSync
(value); }); process.
on
(
'SIGINT'
,
_
=>
{ led.
unexport
(); button.
unexport
(); });