const int potentiometerPin = 34; // Pin connected to the potentiometer
const int ledPin = 2; // Pin connected to the LED
void setup() {
// Initialize Serial communication
Serial.begin(115200);
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the analog input from the potentiometer
int potValue = analogRead(potentiometerPin);
// Map the potentiometer values to LED intensity levels
int ledIntensity = map(potValue, 0, 4095, 0, 255);
// Control the LED intensity using analogWrite
analogWrite(ledPin, ledIntensity);
// Print potentiometer values and LED intensity to Serial Monitor
Serial.print("Potentiometer: ");
Serial.print(potValue);
Serial.print(" | LED Intensity: ");
Serial.println(ledIntensity);
delay(100); // Add a small delay to avoid flickering in the Serial Monitor
}