The iPhone Compass app, available only on the iPhone 3GS and 4, works like a magnetic needle compass. Launch the Compass app by tapping its icon in the Utilities folder on your Home screen, and it shows you the direction you're facing.
But wait — there's more! You can get the iPhone Maps app in on the action:
Tap the little arrowhead icon in the lower-left corner of the Compass screen.
The Maps app launches.
Tap the little arrowhead icon in the lower-left corner of the Maps app two times.
The blue marker that shows you where you are grows a little white cone that indicates the direction you're facing.
When you have your iPhone Maps app in Compass mode, the little arrowhead icon in its lower-left corner grows a little white cone, just like the blue marker, which lets you know that you're now using the Compass mode.
If you rotate to face a different direction while the iPhone Maps app is in Compass mode, the map rotates in real time. So the map always displays the direction you're currently facing, even if you've moved around a bit, which is pretty darn cool.