Instrument Landing System Aircraft ( Marker Beacons)

So we have this project on our avionics class and after searching I found this guide to be effective for marker beacons:

and I have questions for it to fully function as a marker beacon which is like this:

My question is how can I make the LEDs blink and make the piezo buzzer beep.

This is the code that I used from the guide:
#define trigPin 7
#define echoPin 6
#define led 13
#define led2 12
#define led3 11
#define led4 10
#define led5 9
#define led6 8
#define buzzer 3

int sound = 250;

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(buzzer, OUTPUT);

}

void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;

if (distance <= 30) {
digitalWrite(led, HIGH);
sound = 250;
}
else {
digitalWrite(led,LOW);
}
if (distance < 25) {
digitalWrite(led2, HIGH);
sound = 260;
}
else {
digitalWrite(led2, LOW);
}
if (distance < 20) {
digitalWrite(led3, HIGH);
sound = 270;
}
else {
digitalWrite(led3, LOW);
}
if (distance < 15) {
digitalWrite(led4, HIGH);
sound = 280;
}
else {
digitalWrite(led4,LOW);
}
if (distance < 10) {
digitalWrite(led5, HIGH);
sound = 290;
}
else {
digitalWrite(led5,LOW);
}
if (distance < 5) {
digitalWrite(led6, HIGH);
sound = 300;
}
else {
digitalWrite(led6,LOW);
}

if (distance > 30 || distance <= 0){
Serial.println("Out of range");
noTone(buzzer);
}
else {
Serial.print(distance);
Serial.println(" cm");
tone(buzzer, sound);

}
delay(500);
}

I tried adding this codes in the part where an LED turns on.

digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second

but the lights get delayed so much especially when changing distance at fast pace.

I suspect you need to get rid of all the delay() functions and use millis() to manage your time. See the demo several things at a time.

...R

Okay thanks, how about making the buzzer beep?

FFchocobo:
Okay thanks, how about making the buzzer beep?

I know it is a simple sentence but I don't understand what your problem is.
I presume you have a buzzer. Have you been able to write a short program to make it "beep"

(Don't buzzers BUZZ ?)

...R

Robin2:
I know it is a simple sentence but I don't understand what your problem is.
I presume you have a buzzer. Have you been able to write a short program to make it "beep"

(Don't buzzers BUZZ ?)

...R

Haha sorry. what I mean is like this Marker beacon - Wikipedia, the sound they make at a corresponding distance, I have no idea what codes to use..

Please use code tags.

 if (distance <= 30) {
    digitalWrite(led, HIGH);
    sound = 250;
}
  else {
    digitalWrite(led,LOW);
  }
  if (distance < 25) {
      digitalWrite(led2, HIGH);
      sound = 260;
}
  else {
      digitalWrite(led2, LOW);
  }
  if (distance < 20) {
      digitalWrite(led3, HIGH);
      sound = 270;
}
  else {
    digitalWrite(led3, LOW);
  }
  if (distance < 15) {
    digitalWrite(led4, HIGH);
    sound = 280;
}
  else {
    digitalWrite(led4,LOW);
  }
  if (distance < 10) {
    digitalWrite(led5, HIGH);
    sound = 290;
}
  else {
    digitalWrite(led5,LOW);
  }
  if (distance < 5) {
    digitalWrite(led6, HIGH);
    sound = 300;
}

Ah, can't all this be done with a bit of arithmetic? For every 5 units of distance it is closer, you want the sound to go up by 10, is that it?