The one i posted is the complete sketch
No, it isn't, that code doesn't compile.
Could i also try powering the sensor from an external source in your opinion? Or is it something that has nothing to do with what you wrote?
No, do what I told you and post the result. The LEDs need current to light up and that may influence the voltage a bit. And that voltage is the reference for the sensor reading. As the LEDs are switched on and off based on the reading, the influence seems obvious.