const int ledPin = 2; //led connect to pwm pin 5
const int potPin = 13; // potentiometer connected to analog pin A0


void setup(){
  pinMode(ledPin, OUTPUT);
  pinMode(potPin, INPUT);
  Serial.begin(115200);
}

void loop(){
  int potValue = analogRead(potPin);  // read potentiometer value (0-4095)
  Serial.println(potValue);
  // map the potentiometer value to the PWM range (0-255)
  int brightness = map(potValue, 0, 4095, 0, 255);


analogWrite(ledPin, potValue); // set led brightness

delay(10);  // small delay for stability
}