http://www.intomobile.com/2010/10/21/sleep-cycle-iphone-app/
What the app does is use the built-in accelerometer to monitor your movement while you sleep. By monitoring your movement, it determines which ‘sleep phase’ you’re in… and in doing this, it picks the best time to wake you up, within a 30 minute window of the alarm time you initially set.
Read More...