The basic function of sensors are collect a Data pattern from external energy and give binary input to microcontroller or processor, then processor or microcontroller proces that data pattern and give a proper out for perform external activity. It may be any measurement, counting, light, sound or something like other activity in our life etc.
Now be a modern day, Our life is also depending to almost anyone electronics such as mobile, That has anyone one or more sensors(Mobile have multiple sensors for human interact with electronics medium).