const int potPin = 1; // Potentiometer connected to GPIO 1
const int ledPin = 9; // LED connected to GPIO 9
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
Serial.begin(115200);
}
void loop() {
int potValue = analogRead(potPin); // Read the potentiometer value (0 to 4095)
int brightness = map(potValue, 0, 4095, 0, 255); // Convert the potentiometer value to PWM range (0 to 255)
// Set the LED brightness
analogWrite(ledPin, brightness);
Serial.println(potValue);
Serial.println(brightness);
delay(1000); // Small delay for stable operation
}