#include <Servo.h>
int val =0;
Servo servo1;
Servo servo2;
Servo servo3;

bool down = true;

void setup() {
  // put your setup code here, to run once:
  pinMode(A0, INPUT);
  pinMode(A3,OUTPUT);
  pinMode(A3,INPUT);
  
  Serial.begin(9600);
  servo1.attach(4);
  servo2.attach(7);
  servo3.attach(10);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(down);
  Serial.println(digitalRead(A4));
  val= analogRead(A0);
Serial.println(val); //220-970
  while (digitalRead(A4) == HIGH && down == true)
  {
    
    servo2.write(160);
    servo3.write(160);
    delay(1000);
    servo2.write(20);
    servo3.write(20);
    delay(1000);
  }
    servo2.write(20);
    servo3.write(20);
    
  if(val > 250)
  {
    down = false;
    
    servo1.write(105);
    delay(1000);
  }
  else
  {
    down= true;
    
    servo1.write(-160);
    delay(1000);
  }
  
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.