const int potPin = A0;
const int ledPin = 6;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
int adcValue = analogRead(potPin); // Range: 0–1023
int pwmValue = map(adcValue, 0, 1023, 0, 255); // Range: 0–255
analogWrite(ledPin, pwmValue); // Set LED brightness
float dutyCycle = (pwmValue / 255.0) * 100; // Duty cycle in %
Serial.print("ADC: ");
Serial.print(adcValue);
Serial.print(" | PWM: ");
Serial.print(pwmValue);
Serial.print(" | Duty Cycle: ");
Serial.print(dutyCycle, 1);
Serial.println(" %");
delay(500);
}