#include <HCSR04.h>

byte triggerPin = 2;
byte echoCount = 5;
byte* echoPins = new byte[echoCount] { 7, 8, 9, 10, 11 };
int buzzerPin = 12;

void setup () {
  Serial.begin(115200);
  HCSR04.begin(triggerPin, echoPins, echoCount);
}

void loop () {
  double* distances = HCSR04.measureDistanceCm();

  for (int i = 0; i < echoCount; i++) {
    Serial.print(i + 1);
    Serial.print(": ");
    Serial.print(distances[i]);
    Serial.println(" cm");

    if (distances[i] < 50) {
      // Activate the buzzer
      tone(buzzerPin, 262);
    } else {
      // Turn off the buzzer
      noTone(buzzerPin);
    }
  }
  
  Serial.println("---");
  delay(50);
}