const int potPin = A0; // Analog input pin for potentiometer const int ledPin = 9; // PWM enabled pin for LED void setup() { pinMode(potPin, INPUT); pinMode(ledPin, OUTPUT); } void loop() { int sensorValue = analogRead(potPin); // Read potentiometer value (0-1023) int brightness = map(sensorValue, 0, 1023, 0, 255); // Map potentiometer value to LED brightness (0-255) analogWrite(ledPin, brightness); // Set LED brightness using PWM }