A simple circuit which reads a potentiometer (analog input) to control the brightness of an LED.
const int ledPin = 9;
int analogValue = 0;
int brightness = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
analogValue = analogRead(A0);
brightness = analogValue / 4;
analogWrite(ledPin, brightness);
}