#define LED_PIN 9 // PWM pin
#define POT_PIN A0 // Potentiometer
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
int potValue = analogRead(POT_PIN); // 0–1023
int brightness = map(potValue, 0, 1023, 0, 255);
analogWrite(LED_PIN, brightness); // PWM output
}