The MMA7455 accelerometer is a fairly low cost sensor that can measure acceleration in three axes. This sensor is commonly available as a breakout board that you can connect to your Arduino. It only requires VCC, GND , SCA and SCL to be connected.
The wiring diagram is underneath but here is the picture of the sensor breakout we bought which is available from many sources.
You will need a copy of the MMA_7455 library to make your life easier. Download and copy to your Arduino -> Libraries folder
This example simply displays the X, Y and Z axes settings in the serial monitor
#include <Wire.h> //Include the Wire library
#include <MMA_7455.h> //Include the MMA_7455 library
MMA_7455 mySensor = MMA_7455();
char xVal, yVal, zVal;
Serial.println(“MMA7455 Accelerometer Test.”);
xVal = mySensor.readAxis(‘x’); //Read the ‘x’ Axis
yVal = mySensor.readAxis(‘y’); //Read the ‘y’ Axis
zVal = mySensor.readAxis(‘z’); //Read the ‘z’ Axis
Serial.print(“X = “);
Serial.print(” Y = “);
Serial.print(” Z = “);