Watch not responding to shorts, use set interval with a readSync()

This commit is contained in:
mmcwilliams 2017-09-16 14:54:40 -04:00
parent c8f9236a9d
commit 47abb3b8e5
1 changed files with 8 additions and 3 deletions

View File

@ -2,12 +2,17 @@
const Gpio = require('onoff').Gpio
const btn = Gpio(12, 'in', 'both')
const btn = Gpio(18, 'in', 'both')
console.log('Watching input on button 18')
btn.watch((err, val) => {
/*btn.watch((err, val) => {
if (err) {
return console.error(err)
}
console.log(val)
})
})*/
setInterval(() => {
console.log(btn.readSync())
}, 1000)