How to write a sketch using both analogWrite() and analogRead() functions to vary the brightness of the LED with the potentiometer. This is the same concept used in dimmer switch for lighting or volume knob control.
analogWrite basically will produce a PWM as Arduino Uno does not has a DAC (Digital to Analog). Have a look on this example: https://www.arduino.cc/en/Tutorial/Fade
I find that education works best if one does the work involved themselves, and don't just ask others for the answer. Getting tutored is fine, in fact that is the model used by this website. But to gain the most from tutoring, come up with a solution, or a partial solution, then ask for specific help with the part you are stuck on.
Have you run the example musskopf posted? It's also in the File > Examples > Basics ... menu of the Arduino software. What happened when you did, and how did you have it hooked up?
Petir: How to write a sketch using both analogWrite() and analogRead() ...