// ESP32 LED Blink with Potentiometer Speed Control
const int ledPin = 13; // Built-in LED (or use any GPIO)
const int potPin = 34; // Potentiometer connected to GPIO34 (ADC1_CH6)
void setup() {
pinMode(ledPin, OUTPUT); // Set LED pin as output
// No need to set analog pinMode for input - it's default
Serial.begin(115200); // Start serial communication
}
void loop() {
// Read potentiometer value (0-4095)
int potValue = analogRead(potPin);
// Map to delay range (20ms - 2000ms = 2 seconds)
int delayTime = map(potValue, 0, 4095, 100, 2000);
// Blink sequence
digitalWrite(ledPin, HIGH);
delay(delayTime);
digitalWrite(ledPin, LOW);
delay(delayTime);
// Optional serial monitoring (remove if not needed)
Serial.print("Pot Value: ");
Serial.print(potValue);
Serial.print(" | Delay: ");
Serial.print(delayTime);
Serial.println(" ms");
}