   for (uint8_t i = 1; i < SONAR_NUM; i++) // Set the starting time for each sensor.
     pingTimer[i] = pingTimer[i - 1] + PING_INTERVAL;
     
+  // Add the external interupt to the PIR.
+  attachInterrupt(0, isrMotion, RISING);
+    
 }
 
 void loop() 
 {
+  
+  // The motion ISR sets a flag so we know it detected motion.
+  if (bitRead(flags, F_MOTION)) {
+    bitClear(flags, F_MOTION);
+    if (pingPowerState == 0) {
+      // Remember when the cpu woke up.
+      awakeTime = millis();
+    }
+    
+    // Ensure the ping sensors are powered.
+    pingPowerState = 1;
+    // Turn on the ping power.
+    digitalWrite(PIN_PING_POWER, HIGH);
+  }
+  
+  if (pingPowerState == 0) {
+    // Turn off the power to the ping sensors.
+    digitalWrite(PIN_PING_POWER, LOW);
+    
+    // Deep sleep until the next motion.
+    sleepNow();
+  } 
+  
+  
+  
+  
   // PING )))
   for (uint8_t i = 0; i < SONAR_NUM; i++) { // Loop through all the sensors.
     if (millis() >= pingTimer[i]) {         // Is it this sensor's time to ping?

  }
  
  // Other code that *DOESN'T* analyze ping results can go here.
  
  if (millis() - lastTransmit > 1000) {
    // Proof of concept to power cycle the pings
    pingPowerState =!pingPowerState;

    
    transmit(buf); 
  }
  */
  
  
  if (millis() - awakeTime > powerTimeout) {
    //TODO: and not waiting for second sensor
    
    // Powerdown at the start of the next loop
    pingPowerState = 0;
  }
  
}

