const int potPin = 34;  // 滑动变阻器连接到ESP32的模拟引脚A34
const int ledPin = 2;   // LED连接到ESP32的数字引脚D2

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int potValue = analogRead(potPin);  // 读取滑动变阻器的值
  int brightness = map(potValue, 0, 4095, 0, 255);  // 映射到LED的亮度范围

  analogWrite(ledPin, brightness);  // 控制LED的亮度
}