initial commit
This commit is contained in:
parent
b44465ce00
commit
f46517aeb0
17
app.js
Normal file
17
app.js
Normal file
@ -0,0 +1,17 @@
|
||||
const { Gpio } = require( 'onoff' );
|
||||
|
||||
// set BCM 4 pin as 'output'
|
||||
const ledOut = new Gpio( '4', 'out' );
|
||||
|
||||
// set BCM 17 pin as 'input'
|
||||
const switchIn = new Gpio( '17', 'in', 'both' );
|
||||
|
||||
// listen for pin voltage change
|
||||
switchIn.watch( ( err, value ) => {
|
||||
if( err ) {
|
||||
console.log( 'Error', err );
|
||||
}
|
||||
|
||||
// write the input value (0 or 1) 'ledOut' pin
|
||||
ledOut.writeSync( value );
|
||||
} );
|
49
package-lock.json
generated
Normal file
49
package-lock.json
generated
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "test_1",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"epoll": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/epoll/-/epoll-4.0.0.tgz",
|
||||
"integrity": "sha512-dENZbykco5w/vsFHuhD/5zla9VHm3htP1ROoX9MCc6L/7LVqGPFfcGS/g+/+pQLUclKw4uR9HnaZmsZ6fi5n+Q==",
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.14.1"
|
||||
}
|
||||
},
|
||||
"file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
||||
},
|
||||
"lodash.debounce": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
|
||||
"integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168="
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.14.1",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
|
||||
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
|
||||
},
|
||||
"onoff": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/onoff/-/onoff-6.0.0.tgz",
|
||||
"integrity": "sha512-MLWs/s5vU0rfG+oTVXvGz7DIfAeynVEsZAZfbk8AL7gVVSaJerB2UxjkKRdUJIAMVFfdhgsZXZw+5eJAzdWspw==",
|
||||
"requires": {
|
||||
"epoll": "^4.0.0",
|
||||
"lodash.debounce": "^4.0.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
package.json
Normal file
14
package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "test_1",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"onoff": "^6.0.0"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user