MMA8452Q Accelerometer

I got my MMA8452Q Accelerometer up and running, now I want to edit the example code it came with. I want to make it so it will give power to certain pins when I tilt it in different directions. For example, when I turn it to the right, pin 2 will give power, and when I turn it to the left, pin 3 will. Like that but for forward, backward, and side to side. How can I do that?

https://learn.sparkfun.com/tutorials/mma8452q-accelerometer-breakout-hookup-guide/example-code

How can I do that?

digitalWrite() will turn the pin on or off.

An accelerometer measure instantaneous acceleration. There is a fair amount of processing required to get "tilted to the left" from acceleration. Do you know how to do that? Or are you using a library that knows how?