   //The second parameter is for turning debug printing on for the ACI Commands and Events so they be printed on the Serial
   lib_aci_init(&aci_state, false);
   
-  //  Send data every second
+  // Send data every second
   t.every(1000, send_data);
+  // Collect one sonar sensor every 1/4 sec
+  t.every(200, get_data);
   
   Serial.println(F("Set up done"));
 }

  }
}

void get_data(uint16_t *data){
  Serial.println(F("data:"));
  for(int i = 0; i < SONAR_NUM; i++) {
    data[i] = sonar[i].ping_cm();
    if(!data[i]) {
      data[i] = MAX_DISTANCE;
    }
    Serial.print(F(" Sonar"));
    Serial.print(i);
    Serial.print(F(": "));
    Serial.println(data[i]);
  }
}

void send_data(){
  uint16_t data16[SONAR_NUM];
  uint8_t data8[2*SONAR_NUM];
  
  get_data(data16);
  
  for(int i = 0; i < sizeof(data16); i++){
    data8[i*2] = data16[i] & 0xFF;
    data8[i*2 + 1] = (data16[i] & 0xFF00) >> 8;
  }

  uart_tx(data8, sizeof(data8));
}


          lib_aci_change_timing_GAP_PPCP(); // change the timing on the link as specified in the nRFgo studio -> nRF8001 conf. -> GAP.
                                            // Used to increase or decrease bandwidth
          timing_change_done = true;
        }
        break;

