accelerometer problems

I don't know if your problem comes from your code or your circuit so why not showing both? I suspect you didn't have a correct circuit for the LED, which affects the supply voltage of arduino large enough to affect you but without a circuit picture I can only suspect.