     gyroTargetAngle = 360 - gyroTargetAngle;
   }
   if(gyroTargetAngle < 0){
-    gyroTargetAngle = 360 + gyroTargetAngle
+    gyroTargetAngle = 360 + gyroTargetAngle;
   }
   if(gyroTargetAngle < getGyroAngle()){
     leftServo.write(180);


void stopExtinguisher(){
  extinguisher.write(90);
}

//Gyro functions
//Resets the gyro so that the current positioning is angle "0"
void resetGyro(){
  gyroStartAngle = digitalRead(GYRO_PIN);
  gyroTargetAngle = 0;
}

//Returns the current angle of the robot relative to its starting angle
float getGyroAngle(){
  return digitalRead(GYRO_PIN)-gyroStartAngle;
}

//adjusts the target angle based on how much we want to turn and turns the robot until that target is reached

  attachInterrupt(digitalPinToInterrupt(IR_PIN_RIGHT), extinguishFire, RISING);

  pinMode(FLAME_LED, OUTPUT);

  pinMode(MIC_LED, OUTPUT);

  pinMode(BABY_LED, OUTPUT);

  pinMode(CAMERA_LED, OUTPUT);

  setup_gyro();

  FreqCount.begin(1000); // Begin measuring sound
}

void loop() {
// put your main code here, to run repeatedly:

  if (checkingMicrophone) {   //Robot doesn't start until it hears the start frequency
    checkMicrophone();
  }

  startUp();
  levelOneNav();
  delay(100);

  /* if (usingCamera()){    //Only used for CV
    digitalWrite(CAMERA_LED, HIGH);
  } else {
    digitalWrite(CAMERA_LED, LOW);
  }

  if(detectBaby()){
    digitalWrite(BABY_LED, HIGH);
  } else {
    digitalWrite(BABY_LED, LOW);
  } */


  /* if (robotOn) {     //Not entirely sure what this code is for

    extinguishFire();

    delay(100);

    if (detectFire()){
      digitalWrite(FLAME_LED, HIGH);
    } else {
      digitalWrite(FLAME_LED, LOW);
    }

    if (usingCamera()){
      digitalWrite(CAMERA_LED, HIGH);
    } else {
      digitalWrite(CAMERA_LED, LOW);
    }

    if(detectBaby()){
      digitalWrite(BABY_LED, HIGH);
    } else {
      digitalWrite(BABY_LED, LOW);
    }

    if(hearingStartSound){
      digitalWrite(MIC_LED, HIGH);
    } else {
      digitalWrite(MIC_LED, LOW);
    }
  } */
}
