This device tells you how much it is tilting, and in what direction. I'll be using it in the quadcopter project.
At the moment, with the example sketch, it seems very twitchy. Many results can be read per second, each slightly
different although the device hasn't moved. It will require careful programming to give useful results; perhaps collect 100
results and then use the mean average.
|
Accelerometer. The pins are noted in the library; they are sleepPin = 13, selfTestPin = 12, zeroGPin = 11, gSelectPin = 10, xPin = A0, yPin = A1, zPin = A2. |
|
#include <AcceleroMMA7361.h>
AcceleroMMA7361 accelero;
int x;
int y;
int z;
void setup()
{
Serial.begin(9600);
accelero.begin(13, 12, 11, 10, A0, A1, A2);
accelero.setARefVoltage(5); //sets the AREF voltage to 5
accelero.setSensitivity(HIGH); //sets the sensitivity to +/-6G Check Library for LOW/HIGH
accelero.calibrate();
}
void loop()
{
x = accelero.getXVolt();
y = accelero.getYVolt();
z = accelero.getZVolt();
Serial.print("\nx: ");
Serial.print(x);
Serial.print("mV\ty: ");
Serial.print(y);
Serial.print("mV\tz: ");
Serial.print(z);
Serial.print("mV");
delay(500); //make it readable
}
|