#include <Servo.h>

Servo myservo;       // Create a servo object
int potPin = A0;      // Define the analog pin for the potentiometer
int delayTime = 0;    // Variable to store the delay time
int lastUpdateTime = 0; // Variable to store the last update time

const int ledPin = 13;  // LED connected to digital pin 13

void setup() {
  myservo.attach(9);  // Attaches the servo on pin 9
  pinMode(ledPin, OUTPUT);  // Set the LED pin as an output
}

void loop() {
  int potValue = analogRead(potPin);  // Read the potentiometer value
  delayTime = map(potValue, 0, 1023, 100, 5000);  // Map the potentiometer value to delay time 1000 = 1s

  int currentTime = millis();  // Get the current time

  if (currentTime - lastUpdateTime >= delayTime) {
    myservo.write(90);  // Move the servo to the middle position (adjust as needed)
    delay(250);  // Small delay for servo to reach the desired position
    myservo.write(0);   // Move the servo to the minimum position (adjust as needed)

    lastUpdateTime = currentTime;  // Update the last update time
  }

  // Blink the LED every second
  if (currentTime % 1000 == 0) {
    digitalWrite(ledPin, HIGH);
    delay(100);  // Small delay for LED to be visible
    digitalWrite(ledPin, LOW);
  }
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
servo1:GND
servo1:V+
servo1:PWM
pot1:GND
pot1:SIG
pot1:VCC
led1:A
led1:C