Created
May 26, 2012 13:52
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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