I am trying to follow the tutorial for the accelerometer found here: 
http://beagleboard.org/Support/BoneScript/accelerometer/

If I read it right I should be getting back a 1.0 as the resting state on 
the table. However I get back this:


Analog Read Value x: -4.853507815339876
Analog Read Value y: -4.8716830243547795
Analog Read Value z: -4.835332606324972

I am using the ADXL335 Accelerometer and 470-0ohm 1/4 watt carbon film 
resistors from radio shack.

So do I just change the below offset and conversion factor? If so how do I 
find those?

Source code:

var b = require('bonescript');
var zeroOffset  = 0.4584;
var conversionFactor = 0.0917;

function callADC(){
    b.analogRead('P9_36', printX);
    b.analogRead('P9_38', printY);
    b.analogRead('P9_40', printZ);
}

function printX(x) {
    var value = (x.value - zeroOffset)/conversionFactor;
    console.log('Analog Read Value x: ' +value.toFixed(6));    
    // when the ADXL335 resting flat on a table or
    //board, then readings should be x:0
}

function printY(x) {
    var value = (x.value - zeroOffset)/conversionFactor;
    console.log('Analog Read Value y: ' +value.toFixed(6));
    // when the ADXL335 resting flat on a table or
    //board, then readings should be y:0
}

function printZ(x) {
    var value = (x.value - zeroOffset)/conversionFactor;
    console.log('Analog Read Value z: ' +value.toFixed(6));    
    // when the ADXL335 resting flat on a table or 
    //board, then readings should be z:1
    console.log('');
}

//callADC will be invoked 20 times a sec or once every 50 ms
var loop = setInterval(callADC, 250);          

function clear(){
    clearInterval(loop);
}

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to