Trouble with an RGB LED and accelorometer

You are not doing the averaging correctly. What you are doing is a running average. This means that that last sample taken amounts for 50% of the total reading.

Take all the readings and add them up first, then divide by the number of samples you have taken.