Last active
October 6, 2016 04:54
-
-
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
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
'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