 void setup(void)
 {
 	Serial.begin(115200);
-	//Wait until the serial port is available (useful only for the leonardo)
-	while(!Serial)
-	{}
-	Serial.println(F("Arduino setup"));
+	//Wait until the serial port is available (useful only for the Leonardo)
+	#if defined (__AVR_ATmega32U4__)
+		while(!Serial)
+		{}
+	#elif defined(__PIC32MX__)
+		delay(1000);
+	#endif
+
+    Serial.println(F("Arduino setup"));
 	Serial.println(F("Set line ending to newline to send data from the serial monitor"));
 
 	/**

  // print the string when a newline arrives:
  if (stringComplete) {
    Serial.print(F("Sending: "));
    Serial.println(inputString);
    inputString.toCharArray((char*)uart_buffer,20);

    if (inputString.length() > 20)
    {
        uart_buffer_len = 20;
        uart_buffer[19] = '\n';
        Serial.println(F("Serial input truncted"));
    }
    else
    {
        uart_buffer_len = inputString.length();
    }

    if (!lib_aci_send_data(PIPE_UART_OVER_BTLE_UART_TX_TX, uart_buffer, uart_buffer_len))
      {
        Serial.println(F("Serial input dropped"));
      }
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}

/*
  SerialEvent occurs whenever a new data comes in the
 hardware serial RX.  This routine is run between each
 time loop() runs, so using delay inside loop can delay
 response.  Multiple bytes of data may be available.
 Serial Event is NOT compatible with Leonardo, Micro, Esplora
 */
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}

  if (lib_aci_event_get(&aci_state, &aci_data))
  {
    aci_evt_t * aci_evt;
    aci_evt = &aci_data.evt;
    switch(aci_evt->evt_opcode)
    {
