There are three sensors built into the iPhone (and iPod touch) that allow it to perform some of its coolest tricks. They are:
This sensor can determine how close the iPhone is to your face. This sensor is what helps the iPhone turn off its screen automatically whenever you hold the phone up to your ear. This is necessary to prevent accidental button clicks by the side of your head when talking.
This sensor enables the iPhone’s screen to automatically switch from landscape to portrait modes and back again based on whether you’re holding the phone up and down or sideways. This sensor is also present in the iPad.
3.Ambient Light sensor
This sensor can determine how much light is available in the area surrounding the iPhone and iPad and automatically adjust the brightness of the screen in order to conserve battery life.
The iPhone also contains a fourth sensor, though this one isn’t related to the interface. The water sensor is a little red tab that appears in the dock connector when the phone has been submerged in water. It can also appear as a red dot in the headphone jack.
5.iPhone 4 Gyroscope
The iPhone 4 adds another sensor: a three-axis gyroscope. When combining the gyroscope with the accelerometer, this gives the iPhone 4 six axes on which the it can operate. This is designed to make the iPhone 4 more sensitive, responsive, and powerful for gaming.