Skip to content

Instantly share code, notes, and snippets.

@omundy
Created May 26, 2012 13:52
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 omundy/2794039 to your computer and use it in GitHub Desktop.
Save omundy/2794039 to your computer and use it in GitHub Desktop.
Use bonescript and node.js to read from all analog pins on a BeagleBone
/*
* analog-read-all.js
* Use bonescript and node.js to read from all analog pins on a BeagleBone
* Found in the wild:
* https://groups.google.com/forum/#!msg/beagleboard/rftH6aqyR5k/n7jQbCNAL3YJ
*/
var bb = require('./bonescript');
var sys = require('util');
var fs = require('fs');
// default path
ADCPATH = "/sys/bus/platform/devices/tsc/ain";
analogRead = function(pin) {
return fs.readFileSync(ADCPATH + (pin+1));
};
setup = function() {
};
loop = function() {
var i;
for( i = 0; i < 8; i++){
sys.puts("adc" + i + " := " + analogRead(i));
}
delay(1000);
};
bb.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment