The built-in compass (iPhone 3GS only) shows which direction you’re facing, along with the geographical coordinates of your current location. You can choose magnetic north, or have Compass adjust the declination to show true north.
IMPORTANT: The accuracy of digital compass headings may be negatively affected by magnetic or other environmental interference, including interference caused by the close proximity of the magnets contained in the iPhone earbuds. The digital compass should only be used for basic navigation assistance and should not be solely relied on to determine precise locations, proximity, distance, or direction.
The compass needs to be calibrated the first time you use it, and may need to be calibrated occasionally after that. iPhone alerts you whenever calibration is needed.
Wave iPhone in a figure eight. You may be asked to move away from a source of interference.

Hold iPhone level to the ground. The compass needle rotates to point north. Your current direction appears at the top of the screen. The coordinates of your current location are displayed at the bottom of the screen.
Tap
and tap the setting you want.