Led dimmer control circuit demo with serial monitoring

Hi everybody!
I just wrote my first ever control program after using the starter kit tutorials and watching the first 12 videos on programming. I was wondering if anyone would be interested in looking and commenting to give me feedback on my work. I also wanted to be sure that I am posting correctly in the forums as well as uploading sample code. So here goes :slight_smile:
Thanks in advanced for any help…
Rick

/* 
Led dimmer control circuit demo with serial monitoring
Arduino UNO 
Written by Richard Green, yanard3@gmail.com  1/31/2015, 
This example code is in the public domain. Freely distribute :)
*/

int led = 9;                    // pin LED is connected to
int potval = A0;                // pin potentiometer wiper is connected to

void setup()
{ 
  pinMode(led, OUTPUT);         // declare pin 9 to be an output
  pinMode(potval, INPUT);       // declare pin A0 to be an input
  Serial.begin(9600);           // init serial communication (9600 bits per second)
} 

void loop()
{ 
  int potval = analogRead(A0);  // reads voltage on pin A0
  potval = potval / (4);        // sets potval = analogRead divided by 4
  analogWrite(led, potval);     // sets led brightness 0-255
  Serial.println(potval);       // displays potval value in the serial monitor
  delay(50);                    // set delay for loop at 50ms 
}

Ricks_Led_Dimmer.ino (958 Bytes)

  potval = potval / (4);        // sets potval = analogRead divided by 4

(The) (parentheses) (are) (not) (necessary). Nor is the delay().

Otherwise, the code looks fine, and is posted properly (thank you).

Thank You I will fix that....

Rick