I am new on arduino and taking a mechatronics class in which we have to debug this code but we do not know where to start.. Please Help
You just bought a brand new accelerometer and want to use it to determine
which way your device is oriented. So you know that the rst thing you need is
a unit vector describing your gravity vector. So you made this program, but it
doesn't work. Fix it! Remember the square root sum of the squares on a unit
vector should equal 1.0!
int AccelXValue = 0;
int AccelYValue = 0;
int AccelZValue = 0;
oat[3] Vector = [0.0, 0.0, 0.0];
function getAccelXValue
return
oat acceldevice.xReading; . for testing you can simply return
the value 1.1 here
end function
function getAccelYValue
return
oat acceldevice.yReading; . for testing you can simply return
the value 2.2 here
end function
function getAccelZValue
return
oat acceldevice.zReading; . for testing you can simply return
the value 3.3 here
end function
loop . Get values from Accelerometer
AccelXValue = getAccelXValue();
AccelYValue = getAccelYValue();
AccelZValue = getAccelZValue(); . Determine Vector
int magnitude = AccelXV alue2 + AccelY V alue2 + AccelZV alue2;
Vector = [ AccelXV alue=magnitude, AccelY V alue=magnitude, AccelZV alue=magnitude
];
println(Vector); . for testing you'll have to use multiple prints
end loop