intval3/tests/gpio.js

18 lines
279 B
JavaScript
Raw Normal View History

2017-09-16 18:47:33 +00:00
'use strict'
const Gpio = require('onoff').Gpio
2017-09-16 19:07:34 +00:00
const btn = Gpio(5, 'in', 'both')
2017-09-16 18:47:33 +00:00
2017-09-16 19:07:34 +00:00
console.log('Watching input on GPIO 05')
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)*/