Using the Accelerometer
Using the accelerometer is actually quite easy compared to the other hardware components in the iPhone (Microphone and Camera). Firstly you have to know how an accelerometer works. The accelerometer basically measures the pull in each each of the 3 axis (3 dimensions). For example the gravity of Earth will always generate a pull, but what axis it pulls on will tell us how the iPhone is tilted. Inertia will also produce effects on the accelerometer, for instance when someone moves the iPhone or sits with the iPhone in a moving vehicle. The principal behind this is simple, and goes all the way back to Newtons laws of motion "Every body persists in its state of being at rest or of moving uniformly straight forward, except insofar as it is compelled to change its state by force impressed". Imagine that the accelerometer is the following structure:

and in that structure are 3 balls, which can only travel along one of the axis. All of these balls rest in the centre (0.0) until a force pushes them to one end of the line. Now the accelerometer in the iPhone presents the 3 axis in floats, with a range of 1.0 to -1.0 (0.0 being no force applied). The iPhone SDK lets us use a simple Delegate protocol for getting updates from the accelerometer, and it really is as simple as the following code:
Header -
@interface SomeClass : SomeSuperClass <UIAccelerometerDelegate>
This adds the UIAccelerometerDelegate protocol to our interface.
Main -
-(id) init { [UIAccelerometer sharedAccelerometer].delegate = self; return self; } -(void) accelerometer:(UIAccelerometer*)acel didAccelerate:(UIAcceleration*)aceler { float x = aceler.x; float y = aceler.y; float z = aceler.z; }
It's important to note here that we are setting the shared Accelerometers delegate. We can only do this for 1 class in our app, so if more than 1 interface needs to access the accelerometer, it's best to make an interface dedicated to accessing the accelerometer and use that instead of the sharedAccelerometer.