How to remove the gravity from accelerometer

@jremington Dear man, I really thank you anyway for the help that you showed. I hope to figure out with your code because I saw that with mine the not total accuracy influences so much what I want like result. I understand that maybe what I asked could sound weird and pretentious. Thank You for this!