LCD display and ultrasonic sensor not functioning I am doing fish feeder project with level detection for the feeds but lcd display and ultrasonic sensor did not function.

#include &lt;LiquidCrystal.h&gt;
#define trigPin 12              // the trig pin to digital pin 12
#define echoPin 13              // the Echo pin to digital pin 13 
#define L 8
#define M 9
#define H 10
// #define trigmotor 1 //closelid
int led = A1;           // LED indicator to digital pin A1  
#include &lt;Servo.h&gt;
Servo MyServo;

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const int thresholdH = 0;
const int thresholdM = 70;
const int thresholdL = 90;
// defines variables
long duration;
int distance;
float percentLV;


void setup()
{
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(9600); // Starts the serial communication
  pinMode(led,OUTPUT); 
  digitalWrite(led,LOW);            //set the led off(initial condition)
  lcd.begin(16, 2);
}
void loop()
{

int degreesOfRotation = 8;
int servoPinNumber = 11;
float hoursBetweenMeals = 12;
float mealDelayTime = 0;


{ 
    MyServo.attach(11);
    MyServo.write(degreesOfRotation);
    mealDelayTime = hoursBetweenMeals * 1800000;
    delay(20);



    while(degreesOfRotation &lt; 152) {
        MyServo.write(degreesOfRotation);
        delay(10);
        degreesOfRotation += 1;
    }
    while(degreesOfRotation &gt; 8) {
        MyServo.write(degreesOfRotation);
        delay(10);
        degreesOfRotation -= 1;
    }
    delay(mealDelayTime);
}


{ 
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = (duration * 0.034 / 2);
  float percentLV = (40 - ( distance - 16 )) * 100 / 40;


  if (percentLV &gt; thresholdL &amp;&amp; percentLV &lt; 100) {

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("PLEASE REFILL!");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, HIGH);
    digitalWrite(M, LOW);
    digitalWrite(L, LOW);
    //digitalWrite(trigmotor, HIGH);
    //delay(3000);
    //digitalWrite(trigmotor, LOW);
    //delay(1000);
    digitalWrite (led, HIGH);      // Turn on the led indicator
    delay(20);
  } else if (percentLV &lt;= thresholdL &amp;&amp; percentLV &gt; thresholdM) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("U May Refill Now");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, LOW);
    digitalWrite(M, HIGH);
    digitalWrite(L, LOW);
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, HIGH);      // Turn on the led indicator
    delay(20);
  } else if (percentLV &lt;= thresholdM &amp;&amp; percentLV &gt; thresholdH) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Take it easy");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, LOW);
    digitalWrite(M, LOW);
    digitalWrite(L, HIGH);
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, LOW);      // Turn off the led indicator
    delay(20);

  } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("FULL!!");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, LOW);      // Turn off the led indicator
    delay(20);


    Serial.print("PercentLV: ");
    Serial.print(percentLV);
    Serial.println("%");
  }
  delay(1000);

}

}
There doesn't appear to be anything wrong from a quick glance.  Have you got the right library for the LCD?

The chances are there is something wrong with your LCD.  So check your connections again.  Now create a new sketch that just prints hello world on the LCD, or better still use an example.  If that works, then the problem is an interaction between components.

So write a sketch that spins the servo back and forth while printing a message on the LCD.

Did that work, now add in the ultrasonic sensor and the code.

Now the other bits, and if that works, then you could look at what you have done differently, or just thank your lucky stars :)