 Arduino Accelerometer Help

Can someone please help me understand the Z values from the Arduino LilyPad Accelerometer. How can I convert these values into something I understand? What does these numbers mean? Are they in voltage?

When I move the Accelerometer around, up, down, forward, backwards, in circles, tilt…the values don’t seem to be consistent with position.

sigh

An accelerometer measures acceleration not angle of tilt. So the values will differ depending how fast you move it.

So, do the X Y and Z values all complement each other. Will just using the Z values be sufficient enough?

Right now, call all I’m trying to do is change the behavior of the LedPin on the LilyPad Arduino to blink faster or slower in relation to velocity.

Should I be using all all the axis values?

Thanks so much for the response! ;D

for the record, accelerometers make quite nice tilt sensors, because they measure acceleration - gravity happens to be an accereration of about 9.8 m/s - thus, tilting the sensor gives it a reading of gravity at an angle (some simple trig calculates it) and gives you values…

and yes, since it measures acceleration, you will need to be constantly accelerating (or decelating) the sensor relative to a certain axis (that is, in one direction) for you to get different readings

start by just tracking the z axis. If you point z up you’ll see the reading for +1G - probably around 390. If you turn it over so Z is down you’ll see the reading for -1G, probably around 250.

while you’ve got Z straight up or down the other two axes will read neutral values - probably around 320 or so.

If you jerk the accellerometer up (while Z is up) the reading will increase, down it will decrease.

I assume you’re spitting out the values over serial. If you wanted to get a visual reaction you could use the z value to drive a blink loop delay - z up would give you slower blinks than z down.

The other two axes work the same way, of course, but maybe you’ll catch on quickest if you just get one working.

My first accelerometer sketch would just report “Hey, I’m upside down” or “whew - I’m right side up”. I’m pretty easily amused of course. I don’t see that one around but maybe the code below will help a bit as a starting point.

/*
* Accelerometer input
* Takes the input from a lilypad accelerometer on analog pins 0=x, 1=y, 2=z
* converts the values to orientations (+/-90 degrees)
* and sends the orientations to the serial port
*/
int xpin = 0; // select the input pin for the sensor
int xval = 0; // variable to store the value coming from the x axis
int ypin = 1; // select the input pin for the sensor
int yval = 0; // variable to store the value coming from the x axis
int zpin = 2; // select the input pin for the sensor
int zval = 0; // variable to store the value coming from the x axis
int zdir=90;  //initial z orientation is "up"
int up=390; int down=250; int mid=(up+down)/2;
void setup() {
Serial.begin(9600);
}
void loop() {
xval = analogRead(xpin); // read the value from the x axis, 0-1023
yval = analogRead(ypin); // read the value from the y axis, 0-1023
zval = analogRead(zpin); // read the value from the z axis, 0-1023
displayvalues();
delay(100); // rest a little...

}

void displayvalues(){
int zorientation; int yorientation; int xorientation;
//Serial.print("x="); Serial.print(xval);
//Serial.print(" y="); Serial.print(yval);
//Serial.print(" z="); Serial.print(zval);
xorientation=orientation(xval)/10*10;
yorientation=orientation(yval)/10*10;
zorientation=orientation(zval)/10*10;
Serial.print("x="); Serial.print(xorientation);
Serial.print(" y="); Serial.print(yorientation);
Serial.print(" z="); Serial.print(zorientation);

Serial.println("");
}

int orientation(int accelreading) { //changes the reading of an accelerometer input into a degree orientation
//with 90 being straight up, -90 being straight down
int use;                            //the capped reading that i will use here