Using the accelerometer to rotate Camera

I’m wanting to create an app for Android that puts the user into a scene that they can look around by moving their device. Basically using the device as a window into a different world. Obviously the camera will be locked in position but will be able to rotate on the spot. Does anyone know of any code that could do this?

Or, code it yourself: