user13691: Is there a way to adjust the duty cycle (PWM) based upon input gained by a sensor. For example, if the sensor picks up a really high value, it would increase the duty cycle for an LED making it brighter. Can we also do this task without a potentiometer? Can all of this be done "hands-free" by the Arduino?

user14942: The example at the bottom of this Arduino reference page does exactly that. If you want to change the way the value varies, you can just modify the variables in a loop or in whatever approach you prefer instead of analogread'ing it.
https://www.arduino.cc/en/Reference/AnalogWrite

user39824: There is a simple project that can be done with a photo-resistor for an analog input, a light levels sensor circuit, and an LED for an output.
The software requirement is to have a loop with a delay that reads from the analog pin the photo-resistor is attached and use that value to set the Duty Cycle for the PWM output pin driving the LED illumination level.
You can then test by shading the photo-resistor from the ambient light (I used a sheet of paper rolled up into a tube and placed over the photo-resistor on the breadboard), putting it into darkness, and by using a flashlight to provide more light than ambient in order to test the range and watch the LED dim and brighten.
I have done this project with a Raspberry Pi, which required an MCP3008 Analog to Digital Converter to interface to the photo-resistor circuit since the Pi has only digital pins. Arduino has analog pins so the ADC is not necessary.
The project that I did with my Raspberry Pi is at URL: https://github.com/RichardChambers/raspberrypi/tree/master/project08 with C source code and a link to the manufacturer of the experiment kit I am using which has the details for the actual circuit. What I did was to make the LED illumination level track to the inverse of the value reported by the photo-resistor circuit. So when the light level was low as reported by the photo-resistor then I made the LED brighter.

13691: <p>Is there a way to adjust the duty cycle (PWM) based upon input gained by a sensor. For example, if the sensor picks up a really high value, it would increase the duty cycle for an LED making it brighter. Can we also do this task without a potentiometer? Can all of this be done "hands-free" by the Arduino?</p>
 14942: <p>The example at the bottom of this Arduino reference page does exactly that. If you want to change the way the value varies, you can just modify the variables in a loop or in whatever approach you prefer instead of analogread'ing it.</p>

<p><a href="https://www.arduino.cc/en/Reference/AnalogWrite" rel="nofollow">https://www.arduino.cc/en/Reference/AnalogWrite</a></p>
 39824: <p>There is a simple project that can be done with a photo-resistor for an analog input, a light levels sensor circuit, and an LED for an output.</p>

<p>The software requirement is to have a loop with a delay that reads from the analog pin the photo-resistor is attached and use that value to set the Duty Cycle for the PWM output pin driving the LED illumination level.</p>

<p>You can then test by shading the photo-resistor from the ambient light (I used a sheet of paper rolled up into a tube and placed over the photo-resistor on the breadboard), putting it into darkness, and by using a flashlight to provide more light than ambient in order to test the range and watch the LED dim and brighten.</p>

<p>I have done this project with a Raspberry Pi, which required an MCP3008 Analog to Digital Converter to interface to the photo-resistor circuit since the Pi has only digital pins. Arduino has analog pins so the ADC is not necessary.</p>

<p>The project that I did with my Raspberry Pi is at URL: <a href="https://github.com/RichardChambers/raspberrypi/tree/master/project08" rel="nofollow noreferrer">https://github.com/RichardChambers/raspberrypi/tree/master/project08</a> with C source code and a link to the manufacturer of the experiment kit I am using which has the details for the actual circuit. What I did was to make the LED illumination level track to the inverse of the value reported by the photo-resistor circuit. So when the light level was low as reported by the photo-resistor then I made the LED brighter.</p>
