Controlling Fading (brightness) of LED from Potentiometer Using ARDUINO

Posting after so long, Obviously expecting a good stuff from my lab. :), but again I am posting my one more small though important experiment. Its about Controlling Intensity of a LED by varying Potentiometer (as input) using arduino board. Here is the program:

int potIn = 0;                                        // Potentiometer analog input at analog pin 0
int ledPin = 12;                                    // LED at digital Pin 12
int potVal = 0;                                     // Initializing Potentiometer’s input as zero

void setup() {
pinMode(12,OUTPUT);                  // Setting pin 12 as OUTPUT


void loop() {
potVal = analogRead(potIn);         // analog value read at analog pin 0 assigning to potVal
for (int brightness = potVal; brightness <= 200; brightness+=5) {             // for loop for adjusting brightness
analogWrite(ledPin, brightness);                                                                         // value of brightness is analog write to pin 12



Setting whole setup:

Potentiometer had 3 legs out of which middle one is input pin connected to pin 0, whereas pin at one end must be grounded and other end pin must be +5V.

A resistor of 220 ohm between pin 12 and LED must be connected.

LED’s positive leg to output pin 12 and negative leg must be grounded.

Inform me if anyone finds its better and shorter way. see ya guys.