int Ledred1 = 7;
int Ledred2 = 6;
int Ledred3 = 5;
int Buzzer = 3;
int Trigpin = 10;
int Echopin = 9;

long duration, distance;

void setup() {
  // put your setup code here, to run once:
  pinMode(Ledred1, OUTPUT);
  pinMode(Ledred2, OUTPUT);
  pinMode(Ledred3, OUTPUT);
  pinMode(Buzzer, OUTPUT);
  pinMode(Trigpin, OUTPUT);
  pinMode(Echopin, INPUT);
  Serial.begin(9600);
  }

  void loop() {
    // put your main code here, to run repeatedly:
    digitalWrite(Trigpin, LOW);
    delayMicroseconds(2);
    digitalWrite(Trigpin,HIGH);
    delayMicroseconds(10);

    duration = pulseIn(Echopin,HIGH);
    distance = duration*0.034/2;

    Serial.print("Distance: ");
    Serial.print(distance);
    Serial.println("cm");

    if (distance>100) {
    digitalWrite(Ledred1, HIGH);
    digitalWrite(Ledred2, HIGH);
    digitalWrite(Ledred3, HIGH);
    noTone(Buzzer);

    }
    else {
      tone(Buzzer,1000);
      digitalWrite(Ledred1, LOW);
      digitalWrite(Ledred2, LOW);
      digitalWrite(Ledred3, LOW);

    }
  }