This is an easy tutorial showing how you can control the brightness of an LED or adjust the speed of a DC fan using Arduino Board ...
This example code is in the public domain. https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogInput int sensorPin = A0 ...
// the LED has to be connected to PWM digital pin // since LED connected to PWD pin accepts value between 0-255 and potentiometer ...