   lcd.setCursor(12, 0);
   lcd.print(population);
   lcd.setCursor(0, 1);
-  farTrigger = 0;
-  closeTrigger = 0;
+  farLastTime = 0;
+  closeLastTime = 0;
   microsLastRead = micros();
 }
 
+// from tutorial
 float convertRawAcceleration(int aRaw) {
   // since we are using 2G range
   // -2g maps to a raw value of -32768


  // check if it's time to read data and update the filter
  microsNow = micros();
  if (microsNow - microsPrevious >= microsPerReading) {
    float difference = measureYaw() - 180;
    doorAngle = abs(difference);

    if (doorAngle < openAngle) {
      closeDoor();
      Serial.println("Door not open");
    } else if (microsNow - microsLastRead < microsBetweenReads) {
      Serial.println("Movement Detected");
    } else {
      openDoor();
      ping_1 = sonar_1.ping_cm();
      ping_2 = sonar_2.ping_cm();
  
      if (detect(ping_2)) {
        if (closeTrigger > 0) {
          incrementPopulation();
        } else if (!detect(ping_1)) {
          farTrigger = microsNow;
        }
      } else if (detect(ping_1)) {
        if (farTrigger > 0) {
          decrementPopulation();
        } else if (!detect(ping_2)) {
          closeTrigger = microsNow;
        }
      } else {
        if (farTrigger > 0 && microsNow - farTrigger > 2 * microsBetweenReads) {
          farTrigger = 0;
        } else if (closeTrigger > 0 && microsNow - closeTrigger > 2 * microsBetweenReads) {
          closeTrigger = 0;
        }
      }
      printinfo(doorAngle, ping_1, ping_2);

  return a;
}

// from tutorial
float convertRawGyro(int gRaw) {
  // since we are using 250 degrees/seconds range
  // -250 maps to a raw value of -32768
