// LED Brightness Control with Potentiometer
const int potentiometerPin = A0; // Pin connected to the potentiometer
const int ledPin = 9; // Pin connected to the LED
void setup() {
pinMode(potentiometerPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
// Read the value from the potentiometer (0-1023)
int potValue = analogRead(potentiometerPin);
// Map the potentiometer value to the range of PWM (0-255)
int brightness = map(potValue, 0, 1023, 0, 255);
// Set the brightness of the LED
analogWrite(ledPin, brightness);
delay(10); // Delay for stability
}