I suggest you start with a simple program that can run the fan for (say) 5 seconds in each direction.
Then extend the program so that can run the fan at different speeds.
Then another program to get data from the compass and accelerometer and display them on the Arduino Serial Monitor.
Have a look at Planning and Implementing a Program
And for receiving data on your Arduino have a look at the examples in Serial Input Basics - simple reliable ways to receive data.
...R