intval3/tests/gpio.js

18 lines
282 B
JavaScript
Raw Normal View History

2017-09-16 18:47:33 +00:00
'use strict'
const Gpio = require('onoff').Gpio
const btn = Gpio(18, 'in', 'both')
2017-09-16 18:47:33 +00:00
console.log('Watching input on button 18')
/*btn.watch((err, val) => {
2017-09-16 18:47:33 +00:00
if (err) {
return console.error(err)
}
console.log(val)
})*/
setInterval(() => {
console.log(btn.readSync())
}, 1000)