Sensors determine where the spacecraft is pointed, how fast it is turning, and how its speed is changing.
Sixteen sensors (eight of them backups) deployed around the spacecraft body provide knowledge of where the Sun is located. These sensors are pretty simple, and only give two answers: "I see the Sun" or "I don't see the Sun." The computer and flight software listen to all of the sensors to deduce the Sun's location based on that information. Since the spacecraft relies on sunlight to create electrical power, this function is very important.
The Sun sensors normally are used only when first waking up the spacecraft, for example, after launch and during spacecraft emergencies -- instances when the spacecraft may not know where it is pointed.
The Sun sensors provide enough information so the spacecraft can continue to get power from the Sun, but they don't give enough information for other things, like finding the Earth or a spot on Mars. For that, more sophisticated sensors coupled with computer software are required (see below).
Two star trackers provide full knowledge of the spacecraft's orientation, allowing the spacecraft to know not only where the Sun is, but also where Earth and Mars are and how to point in any direction in the sky (necessary when doing a maneuver). As is the case with many components aboard Mars Reconnaissance Orbiter, the second star tracker is a backup in case the first one fails.
The star tracker is a very smart camera that takes a digital picture of the stars and then compares the image with those in its own catalog of thousands of stars to identify the stars in the image. Once it does that, it knows exactly where it was pointing when it took the picture, and it sends a message to the computer conveying that information. And, it does that 10 times every second!
Two inertial measurement units are on board (the second for backup purposes). Each is a combination accelerometer and ring laser gyroscope. The accelerometer measures acceleration (changes in speed) so the spacecraft can know things like when it has fired its rocket engines for long enough. The gyroscope measures how fast the spacecraft is turning. With this information, the spacecraft can tell how far it has turned so it knows when to stop. The gyro can also estimate the spacecraft's orientation for short periods, when, for example, the spacecraft is turning too fast for the star tracker to work properly. Each inertial measurement unit has three gyroscopes and three accelerometers -- one gyro and one accelerometer for each axis of the spacecraft.