Dim LED with level Sensor

You haven't explained HOW the level sensor is connected. The analog pins are for measuring voltage, not resistance. Knowing the resistance of the sensor at each extreme is necessary to choosing an appropriate resistor to form a voltage divider, to maximize the range of values returned by the ADC.

It is still necessary to connect the resistor and sensor to the Arduino correctly. It isn't clear that you have done that.

You could also add Serial.print() statements to loop() (and Serial.begin() to setup()) to see what actual data you are getting from the analog pin.