Demo on auto scaling map ranges for analog sensors to suit different environments.
Note that when you first turn on the Arduino you may get spikes in your analog read values, which can throw off the accuracy of the auto mapping. This is why I've added the delay to setup; to let the system stabilize before the auto mapping process starts.
If I actually wanted to analogWrite a LED I'd need to use a digital pin with PWM.