Skip to content

Instantly share code, notes, and snippets.

@w4ilun
Created September 30, 2016 20:48
Show Gist options
  • Save w4ilun/344c3cd6babdb025474d71500c9da139 to your computer and use it in GitHub Desktop.
Save w4ilun/344c3cd6babdb025474d71500c9da139 to your computer and use it in GitHub Desktop.
var mraa = require('mraa');
var version = mraa.getVersion();
if (version >= 'v0.6.1') {
console.log('mraa version (' + version + ') ok');
}
else {
console.log('mraa version(' + version + ') is old - this code may not work')
}
var ads1115 = new mraa.I2c(0);
ads1115.address(0x49)
setInterval(function(){
//A4
ads1115.writeWordReg(1, 0x83C1);
//A5
// ads1115.writeWordReg(1, 0x83D1);
//A6
// ads1115.writeWordReg(1, 0x83E1);
//A7
// ads1115.writeWordReg(1, 0x83F1);
var raw = ads1115.readWordReg(0);
var analogValue = ((raw&0xff00)>>8)+((raw&0x00ff)<<8);
console.log(analogValue);
}, 200);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment