#define INPUT_PIN 4   // Pin 2 as input
#define OUTPUT_PIN 1   // Pin 1 as output
#define SERVO_PIN 0    // Pin 4 for the servo

unsigned long prevTime=millis();
unsigned long currentTime=0;

int minDelay = 2;     // Minimum delay time for the motor
int maxDelay = 10;    // Maximum delay time for the motor

void moveServo(int degrees) {
  // Calculate the pulse width for the servo
  int pulseWidth = map(degrees, 0, 180, 500, 2400); // Map the degrees to pulse width range
//  Serial.println(pulseWidth);

  // Generate the PWM signal for the servo
  digitalWrite(SERVO_PIN, HIGH);  // Set the signal high
  delayMicroseconds(pulseWidth);  // Wait for the specified pulse width
  digitalWrite(SERVO_PIN, LOW);   // Set the signal low

  // Delay to allow the servo to settle
  delayMicroseconds(10);
}

void setup() {
  //Serial.begin(9600);
  pinMode(INPUT_PIN, INPUT);     // Set Pin 2 as input
  pinMode(OUTPUT_PIN, OUTPUT);   // Set Pin 1 as output
  pinMode(SERVO_PIN, OUTPUT);    // Set Pin 4 as output for servo
}

void loop() {
  
  //digitalWrite(OUTPUT_PIN, LOW);  // Set Pin 1 low
  currentTime=millis();

  if (digitalRead(INPUT_PIN) == HIGH) {
    // Object detected
  
 if (currentTime-prevTime>5000)
  {
    digitalWrite(OUTPUT_PIN,HIGH);


      prevTime=currentTime;
  }                   
else 
    digitalWrite(OUTPUT_PIN,LOW);

  }    

  //if a button is pressed-> servo mode on
  //stay at fist position for half of the time
  //move to the final position instantly and stay there for half time of the delay
  //or one thing more can be done is stays 5 seconds on upward and 5 second downward
  //moveServo(100);   
}
ATTINY8520PU
tiny:PB5
tiny:PB3
tiny:PB4
tiny:GND
tiny:PB0
tiny:PB1
tiny:PB2
tiny:VCC
led1:A
led1:C
r1:1
r1:2
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
vcc1:VCC
vcc2:VCC
gnd1:GND
servo1:GND
servo1:V+
servo1:PWM
gnd2:GND
vcc3:VCC