#include<Arduino.h>
const int potPin = 34; // Pin connected to the potentiometer (use GPIO 34 for analog input on ESP32)
const int ledPin = 2; // Pin connected to the LED (change this to any available GPIO pin)
void setup() {
Serial.begin(9600); // Start serial communication
pinMode(ledPin, OUTPUT); // Set LED pin as output
}
void loop() {
int potValue = analogRead(potPin); // Read the potentiometer value (0-4095)
// For debugging: Print the raw potValue to the Serial Monitor
Serial.print("Potentiometer Value: ");
Serial.println(potValue);
delay(500); // Short delay for stability
// Basic LED control test: If potentiometer value is above midpoint, turn on LED
if (potValue > 2048) {
digitalWrite(ledPin, HIGH); // Turn on LED if potentiometer value is above the midpoint
} else {
digitalWrite(ledPin, LOW); // Turn off LED otherwise
}
}