Instrument Landing System Aircraft ( Marker Beacons)


so have project on our avionics class , after searching found guide effective marker beacons:

http://www.instructables.com/id/arduino-distance-detector-with-a-buzzer-and-leds/?allsteps

and have questions function marker beacon this:

http://en.wikipedia.org/wiki/marker_beacon

my question how can make leds blink , make piezo buzzer beep.

this code used 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 codes in part led turns on.

  digitalwrite(led, high);   // turn led on (high voltage level)
  delay(1000);               // wait second
  digitalwrite(led, low);    // turn led off making voltage low
  delay(1000);               // wait second

but lights delayed when changing distance @ fast pace.

i suspect need rid of delay() functions , use millis() manage time. see demo several things @ time.

...r


Arduino Forum > Using Arduino > Project Guidance > Instrument Landing System Aircraft ( Marker Beacons)


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code