There are three sensors built into the iPhone that allow it to perform some of its coolest tricks. They are:
Proximity sensor – 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.
Motion sensor/accelerometer – 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.
Ambient Light sensor – This sensor can determine how much light is available in the area surrounding the iPhone 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.

