Making an Arduino Uno recognise whether the frequency/sound on A0 is correct

I’m playing a standard seatbelt chime of 2kHz into a microphone, then into a LM321 op amp with a gain of 10. Then the op amp output into an Arduino Uno with an LCD display that comes with an Arduino Starter Kit and an LED indicator.

I’m trying to get the Arduino to recognise whether the seatbelt chime is happening and if it is the correct sound. If it is incorrect, I want it to display how many times it fails on the LCD display.

As a beginner, this is how far I’ve gotten:

#include <LiquidCrystal.h>

int greenLED = 8;
int mic = A0;
int micstate = 0;
int counter = 0;
int rs = 12;
int en = 11;
int d4 = 5;
int d5 = 4;
int d6 = 3;
int d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // put your setup code here, to run once:
  pinMode(greenLED, OUTPUT);
  pinMode(mic, INPUT);
  Serial.begin(115200); //9600
  lcd.begin(16, 2);
  lcd.print("Hello!");
  lcd.setCursor(0, 1);
  delay(2000);
  lcd.clear();
  lcd.print("Number of Fails:");
}

void loop() {
  // put your main code here, to run repeatedly:
  lcd.setCursor(0, 1);
  lcd.print(counter);
  micstate = analogRead(mic);
  //greenLED turns on when mic reading is between 400 and 500
  if (micstate <= 500 && micstate <= 400) {
    digitalWrite(greenLED, HIGH);
    Serial.println(micstate);
  }
  else digitalWrite(greenLED, LOW);
  Serial.print("FAIL: ");
  Serial.println(micstate);
  counter = counter + 1;
  lcd.print(counter);
}

It works at this stage but I don’t want the time between the “beep” of the chime to show as a fail. I’d like the Arduino to recognise that “beep____beep____beep____beep____beep” is a pass and “beep_beep_beep_beep_beep” is a fail.

If it helps, more seatbelt chime specs:
Initial duty cycle = 50%
ON time = 500ms
Base time = 1000ms
Duration = max of 90 seconds for each event
Number of base times = 90

Any help would be greatly appreciated!

I’d like the Arduino to recognise that “beep____beep____beep____beep____beep” is a pass and “beep_beep_beep_beep_beep” is a fail.

All you know, now, is whether the voltage at the pin is between some lower limit and some upper limit. You need to record when the value goes above the limit and when it goes below the limit, so you can distinguish between beep and beeeeeeeep, and between beep____beep and beepbeep or beep_____________beep.

So, you need to start with two changes. First, you need to record the previous value, so you can detect when the current value is within the thresholds while the previous value was not (the start of the beep), and when the current value is not but the previous value was (the end of the beep).

Second, you need to determine when each change happens, so you know how long a beep or a pause lasts. Whether you use millis() or micros() depends on the duration of a beep or a pause.

Then, you need to recognize that you have no way of knowing what sound the microphone picked up. It may, or may not, have been that of the beeper. THAT is a much more difficult problem to deal with.

Is it possible to explain this in a different way so that I can wrap my head around it please?