// Pin Definitions
const int potPin = A0; // Potentiometer connected to A0
const int ledPin = 9; // LED connected to pin 13 (or any output pin)
// Variables
int potValue ; // Variable to store potentiometer value
long delayTime; // Variable to store delay time in milliseconds
void setup() {
pinMode(potPin, INPUT);
pinMode(ledPin, OUTPUT); // Set LED pin as output
Serial.begin(9600); // Begin serial communication for debugging
}
void loop() {
// Read the potentiometer value
potValue = analogRead(potPin);
// Map the potentiometer value to a delay range (1 to 10 minutes)
delayTime = map(potValue, 0, 1023, 60000, 600000);
analogWrite(ledPin,delayTime);
// Debugging: Print the mapped delay time
Serial.print("Potentiometer Value: ");
Serial.print(potValue);
Serial.print(" | Delay Time (ms): ");
Serial.println(delayTime);
// Toggle the LED with the calculated delay
digitalWrite(ledPin, HIGH); // Turn LED on
delay(delayTime); // Wait for the mapped delay time
digitalWrite(ledPin, LOW); // Turn LED off
delay(delayTime); // Wait for the mapped delay time
}