Para que fuera SerialUSB deberías haber definido el objeto SoftwareSerial indicando los pines para TX y RX. No esta en tu código así que corrige por Serial a secas.
Ahhh será que el Zero requiere eso? no lo sabía. Prueba mientras lo investigo.
Esto acabo de encontrar acerca del Zero
Serial - Puerto de programación (la ruta es SAMD->uart->EDBG->usb->PC)
Serial1 - Serial uart en pines 0 and 1
SerialUSB - Puerto nativo, Es un serial port emulado (USB-CDC)
Si estas usando SerialUSB y quieres ver los primeros datos enviados por el micro tienes que poner esto al comienzo del sketch esperando a que alguien abra el monitor Serie :
SerialUSB.begin(9600);
while (!SerialUSB) {
; // wait for serial port to connect
}
/* Wait for transfer to complete /
while (!udd_is_OUT_transf_cplt(ep));
/ Clear Transfer complete 0 flag */
udd_clear_OUT_transf_cplt(ep);
return udd_ep_out_cache_buffer[ep][0];
}
I discovered that when sending a string with a size x, the next string of the same size was read correctly. But if the next string had different size was not read correctly. So I commented the line where it was setted the size of the string to be read, getting this with a constant size. Now I have a 64 bytes size string that I can read without problems.