// Define the pin for the LED and potentiometer
const int ledPin = 13;
const int potPin = A0;
void setup() {
// Initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
// Initialize the serial communication for debugging (optional)
Serial.begin(9600);
}
void loop() {
// Read the value from the potentiometer
int potValue = analogRead(potPin);
// Map the potentiometer value (0-1023) to a suitable delay time (e.g., 100-1000 ms)
int delayTime = map(potValue, 0, 1023, 100, 1000);
// Print the potentiometer value and delay time for debugging (optional)
Serial.print("Potentiometer Value: ");
Serial.print(potValue);
Serial.print(" Delay Time: ");
Serial.println(delayTime);
// Turn the LED on
digitalWrite(ledPin, HIGH);
// Wait for the mapped delay time
delay(delayTime);
// Turn the LED off
digitalWrite(ledPin, LOW);
// Wait for the mapped delay time
delay(delayTime);
}