Is it possible to set the x,y,z axis values to 0 at initialization?
I am basically utilizing the accelerometer as a motion detector and will trigger an action based on a threshold that I set for each axis.
Thank You
Is it possible to set the x,y,z axis values to 0 at initialization?
I am basically utilizing the accelerometer as a motion detector and will trigger an action based on a threshold that I set for each axis.
Thank You
Yes, it is possible
Do you have an example of the code I would need for an ADXL345 or an MMA7361 three axis accelerometer?
Regards
If you show us the code you currently have to read the accelerometer, we can show you where to slot in the additional code
My code is very basic, I just set it up to get x,y,z, values.
void setup()
{
Serial.begin(9600);
}
void loop()
{
int xaxis = analogRead(1);
xaxis = map(xaxis, 0, 1023, 0, 255);
int yaxis = analogRead(2);
yaxis = map(yaxis, 0, 1023, 0, 255);
int zaxis = analogRead(3);
zaxis = map(zaxis, 0, 1023, 0, 255);
Serial.print("x-axis");
Serial.print("\t");
Serial.println(xaxis);
Serial.print("y-axis");
Serial.print("\t");
Serial.println(yaxis);
Serial.print("z-axis");
Serial.print("\t");
Serial.println(zaxis);
Serial.println("");
delay(1000);
}