   
   float g = (gRaw * 250.0) / 32768.0;
   return g;
+}
+
+boolean detect(int pingValue) {
+  return pingValue < thresh && pingValue > 0;
 }
 
 void printinfo(float doorAngle, int ping_1, int ping_2) {

    float difference = measureYaw() - 180;
    doorAngle = abs(difference);

    ping_1 = sonar_1.ping_cm();
    ping_2 = sonar_2.ping_cm();
    printinfo(doorAngle, ping_1, ping_2);

    // increment previous time, so we keep proper pace
    microsPrevious = microsPrevious + microsPerReading;

  return filter.getYaw();
}

void incrementPopulation() {
  population++;
  updatePopulationAndMoveCursor();
  lcd.write("Welcome!        ");
}

void decrementPopulation() {
  if (population > 0) {
    population--;
  }
  updatePopulationAndMoveCursor();
  lcd.write("Have a nice day!");
}

void openDoor() {
  if (!doorOpen) {
    lcd.setRGB(0, 255, 0);
    doorOpen = true;
  }
}

void closeDoor() {
  if (doorOpen) {
    lcd.setRGB(255, 255, 255);
    doorOpen = false;
  }
}

// Update population and move cursor to where the message will be written
void updatePopulationAndMoveCursor() {
  lcd.setCursor(12, 0);
  lcd.write("    ");
  lcd.setCursor(12, 0);
  lcd.print(population);
  lcd.setCursor(0, 1);
  farTrigger = 0;
  closeTrigger = 0;
  microsLastRead = micros();
}

float convertRawAcceleration(int aRaw) {
  // since we are using 2G range
  // -2g maps to a raw value of -32768
