// Define pin numbers
const int potPin = A0; // Potentiometer connected to A0
const int ledPin = 3;  // LED connected to pin 3 (PWM pin)

void setup() {
  // Initialize the LED pin as an output
  pinMode(ledPin, OUTPUT);
  // Initialize the potentiometer pin as an input
  pinMode(potPin, INPUT);
}

void loop() {
  // Read the value from the potentiometer
  int potValue = analogRead(potPin);
  
  // Map the potentiometer value from 0-1023 to 0-255 (PWM range)
  int ledBrightness = map(potValue, 0, 1023, 0, 255);
  
  // Set the brightness of the LED
  analogWrite(ledPin, ledBrightness);
  
  // Small delay to stabilize readings
  delay(10);
}