const int potPin = 10; // Analog pin for potentiometer input const int pwmPin = 39; // PWM pin for output const int ledPin = 15; // Built-in LED pin void setup() { // Initialize serial communication for debugging Serial.begin(9600); // Set PWM pin and LED pin as outputs pinMode(pwmPin, OUTPUT); pinMode(ledPin, OUTPUT); } void loop() { // Read the value from the potentiometer int potValue = analogRead(potPin); // Map the potentiometer value (0-1023) to PWM range (0-255) int dutyCycle = map(potValue, 0, 1023, 0, 255); // Output the duty cycle analogWrite(pwmPin, dutyCycle); // Print potentiometer value and corresponding duty cycle Serial.print("Potentiometer Value: "); Serial.print(potValue); Serial.print(" Duty Cycle: "); Serial.println(dutyCycle); // Blink the built-in LED digitalWrite(ledPin, HIGH); delay(500); digitalWrite(ledPin, LOW); delay(500); }