Control the PWM duty cycle with the conversion value of the ADC
This code shows:
-How to use ADC in polling mode and get the converted value.
-How to set the ADC peripheral in continuos mode for a single channel conversion.
-How to use the TIMER 2 CHANNEL 1 to generate the PWM which changes the brightness of the LED.
-How to change the duty cycle in runtime and set the value in the comparator register.
NOTE: In this example we use a potentiometer to change the voltage input from 0 V to 3.3 V.