Starting a function with a sound

Hello, we're trying to make a line following car using arduino which is activated by a 1800 Hz sound. We've got the line following part of the code and a working microphone and filter. But we can't figure out the code to make the car start with 1800 Hz.
I've put the "driving part" as a function in the code, but I don't know how to make the arduino run that function after hearing this sound once. At the moment it runs the function if the sound is above 1800 Hz, but it won't keep it running when it's lower than 1800 Hz

Summary: It need to start a function after hearing 1800 Hz once, and keep it running regardless of further incoming sound.

The Code:

int val = 0;
int freq = 0;
int counter = 0;
unsigned long timer = 0;
unsigned long start_time = 0;

int ENA = 3; //Enable Pin of the Right Motor (must be PWM)
int IN1 = 1; //Control Pin
int IN2 = 7;

int ENB = 6; //Enable Pin of the Left Motor (must be PWM)
int IN3 = 4;
int IN4 = 5;

//Speed of the Motors
#define ENASpeed 100
#define ENBSpeed 100

int Sensor1 = 0;
int Sensor2 = 0;
int Sensor3 = 0;

void setup() {

pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);

pinMode(ENB, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);

pinMode(Sensor1, INPUT);
pinMode(Sensor2, INPUT);
pinMode(Sensor3, INPUT);

Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(2),count,RISING);
}

void loop() {
// put your main code here, to run repeatedly:
timer = millis();
if((timer - start_time) > 100) {
freq = counter * 10;
start_time = millis ();
Serial.println(freq);
counter = 0;
if (freq >= 1800) { //Don't know how to make it work after hearing the sound once here
driving ();
}
}

}

int driving () {
//Use analogWrite to run motor at adjusted speed
analogWrite(ENA, ENASpeed);
analogWrite(ENB, ENBSpeed);

//Read the Sensor if HIGH (BLACK Line) or LOW (WHITE Line)
Sensor1 = digitalRead(8);
Sensor2 = digitalRead(9);
Sensor3 = digitalRead(10);

//Set conditions for FORWARD, LEFT and RIGHT

if(Sensor3 == HIGH && Sensor1 == LOW){

//Turn LEFT
//motor A Backward
Serial.println(1010101);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);

//motor B Forward
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}

else if (Sensor3 == LOW && Sensor1 == HIGH){

//Turn RIGHT
//motor A Forward
Serial.println(2020202);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);

//motor B Backward
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}

else if(Sensor3 == LOW && Sensor1 == LOW) {

//FORWARD
Serial.println(3030303);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
}

void count() {
counter = counter +1; }

but it won't keep it running when it's lower than 1800 Hz

Correct. You need to create a boolean variable, with an initial value of false. Set the variable to true when the correct sound is detected.

Then, modify loop:

void loop() {
  // put your main code here, to run repeatedly:
timer = millis();
if((timer - start_time) > 100) {
  freq = counter * 10;
  start_time = millis ();
  Serial.println(freq);
  counter = 0;
  if (freq >= 1800) {       //Don't know how to make it work after hearing the sound once here
    needToDrive = true;
  }
    }

                 if(needToDrive)
            {
                                    driving();
       }
}

Be sure to keep the piss-poor indenting. It is sure to impress your teacher.

Thanks Paul you helped us out big time! We've tried to thank you earlier but somehow my last post here didn't come through