// Middle leg of the potentiometer: A0 const int POT_PIN = A0; // LED on ~9: analogWrite needs a PWM pin const int LED_PIN = 9; void setup() { pinMode(LED_PIN, OUTPUT); Serial.begin(9600); } void loop() { // From 0 (one end) to 1023 (the other) int potValue = analogRead(POT_PIN); // Turn 0–1023 into PWM's 0–255 int brightness = map(potValue, 0, 1023, 0, 255); analogWrite(LED_PIN, brightness); Serial.print("Potentiometer: "); Serial.print(potValue); Serial.print(" Brightness: "); Serial.println(brightness); delay(200); }