For the accelerometer I used the following tutorial: http://code.tutsplus.com/tutorials/using-the-accelerometer-on-android--mobile-22125
For the compass I used the following tutorial: https://www.javacodegeeks.com/2013/09/android-compass-code-example.html
The compass image was taken from: http://vignette2.wikia.nocookie.net/community-sitcom/images/1/17/COMPASS.png/revision/latest?cb=20140523185140