// map the sensor value from the input range (400 - 900, for example) to the output range (0-255): int brightness = map(sensorValue, 400, 900, 0, 255); analogWrite(ledPin, brightness);