Arduino Uno project

//SM Innovative Idias Automatic Water Tap - Code

#include <Servo.h>
Servo servoMain; // Define Servo motor
int trigpin = 5;
int echopin = 6;
int distance;
float duration;
float cm;

void setup()
{
servoMain.attach(7); // connect servo motor on digital pin 7
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
}

void loop()
{
digitalWrite(trigpin, LOW);
delay(2);
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(trigpin, LOW);
duration = pulseIn(echopin, HIGH);
cm = (duration/58.82);
distance = cm;

if(distance<20)
{
servoMain.write(90); // Turn Servo back to center position (90 degrees)
delay(100);
}
else{
servoMain.write(0);
delay(50);
}

}

Please apply code tags as described in https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#posting-code.

You can edit your post, select all code and click the <CODE/> button. Next save your post.

===
Do you have a problem? If so, give a good description.
Also let us know which board you're using.

@aditya_1237_000
Post your code following these instructions.

आदित्य,
इन निर्देशों का पालन करते हुए अपने कोड को कोड ब्लॉक में प्रारूपित करें। धन्यवाद।

That servo is gonna jitter like a caffeinated meerkat with that code.

Can you post an annotated schematic showing exactly how you have wired this project? Is this for a class, if so which one?