Skip to content

Instantly share code, notes, and snippets.

@rxseger
Last active October 6, 2016 04:54
Show Gist options
  • Save rxseger/f141e039e0fb84839483105d52c04c7c to your computer and use it in GitHub Desktop.
Save rxseger/f141e039e0fb84839483105d52c04c7c to your computer and use it in GitHub Desktop.
read all 8-channels on MCP3304 for testing https://github.com/fivdi/mcp-spi-adc/pull/1
'use strict';
var mcpadc = require('../');
function readadc(channel, cb) {
var adc = mcpadc.openMcp3304(channel, {speedHz: 20000}, function (err) {
if (err) throw err;
adc.read(cb);
});
}
for (var i = 0; i < 8; ++i) {
readadc(i, function(i, err, reading) {
console.log(i + ' = ' + (reading.value * 3.3));
}.bind(null, i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment