initial
This commit is contained in:
22
node_modules/onoff/examples/wait-for-interrupt.js
generated
vendored
Normal file
22
node_modules/onoff/examples/wait-for-interrupt.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
const Gpio = require('../onoff').Gpio; // Gpio class
|
||||
|
||||
// Export GPIO4 as an interrupt generating input with a debounceTimeout of 10
|
||||
// milliseconds
|
||||
const button = new Gpio(4, 'in', 'rising', {debounceTimeout: 10});
|
||||
|
||||
console.log('Please press the button on GPIO4...');
|
||||
|
||||
// The callback passed to watch will be invoked when the button connected to
|
||||
// GPIO4 is pressed
|
||||
button.watch(function (err, value) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log('Button pressed!, its value was ' + value);
|
||||
|
||||
button.unexport(); // Unexport GPIO and free resources
|
||||
});
|
||||
|
Reference in New Issue
Block a user