do you have to set a resistor with an LED?

Hi, i am wondering if it is completely necessary to have a 220 resistor with an LED? what if you program a potentiometer to control the LED brightness using analogRead. and analogWrite to then insert that value into the LED brightness spectrum? since the potentiometer control the amount of voltage going into the LED is it safe for the LED to be operated like that without an actual resistor?

and is this also safe for the pin that is sending the 5V current to the LED light?

since the potentiometer control the amount of voltage going into the LED

Using a PWM output sends a series of pulses at 5V, so the pot is not actually changing the voltage sent to the LED thus a current limiting resistor is still needed.

is this also safe for the pin that is sending the 5V current to the LED light?

The terms used in this question are very mixed up but I think you are asking whether an Arduino pin can supply the current required to drive an LED. An Arduino pin can supply 40mA so as long as that limit is respected the answer is yes.

Note, however, that the voltage regulator on most Arduinos can only supply a total of 200mA