Skip to content

Instantly share code, notes, and snippets.

@EnotionZ
Created August 10, 2012 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EnotionZ/3311636 to your computer and use it in GitHub Desktop.
Save EnotionZ/3311636 to your computer and use it in GitHub Desktop.
Cycle voltage on Raspberry Pi gpio header in node
var gpio = require('gpio');
var header4, header17, intervalTimer;
header4 = gpio.export(4);
header17 = gpio.export(17, {
ready: function() {
intervalTimer = setInterval(function() {
header4.set();
setTimeout(function() { header4.reset(); }, 500);
}, 1000);
header4.on('change', function(val) { header17.set(1-val); });
}
});
// after 10 seconds, reset all the headers, unexport and quit program
setTimeout(function() {
clearInterval(intervalTimer);
header4.removeAllListeners('valueChange');
header4.reset();
header4.unexport();
header17.reset();
header17.unexport(function(){
process.exit();
});
}, 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment