"Serial does not name a type error"
if (safetyDistance &gt; 5 &amp;&amp; safetyDistance &lt;= 10) {
    digitalWrite(buzzer, HIGH);
    digitalWrite(ledPin, HIGH);

    tone(buzzer, 3000);
    delay(3000);
    noTone(buzzer);
    delay(3000);
  } else {
    digitalWrite(buzzer, LOW);
    digitalWrite(ledPin, LOW);
  }
  }                           //&lt;--
  Serial.print("Distance: ");
  Serial.println(distance);

}


There is a duplicate } after the else clause is closed. Remove it and your code will compile.