Serial ports and AD converter

Serial Ports

On Arduino M0 and M0PRO main serial ports are: Serial, Serial5 and SerialUSB. 
Serial is the port for EDBG (only for M0PRO), Serial5 uses pin 0 and 1, SerialUSB is the native USB port. 
When you use Serial, because this port is shared with EDBG, in the sketch after the instruction “Serial.begin(MY BAUDRATE);” add a delay, for example write “delay(6000);” then when you open serial monitor you can view whitout any problem debug messages of the sketch. 
For the other serial ports delay istruction is unnecessary.

A/D converter

The function “analogReference(ref)” sets voltage ref for A/D converter on M0 and M0PRO and requires one parameter (ref). 
Possible value for ref are:


In this case Vref is VDDana, because VDDana is 3.3 V than Vref is 3.3 V.

In this case Vref=1 V

Vref is variable according to the voltage applied on VREF pin available on the board. 
Pay attention to not exceed VDDana-0,6 V (3,3-0,6=2,7 V) on the VREF pin because ATSAMD21G18A doesn't tolerate voltages above the value written before, as reported on datasheet.


The function sets the output resolution of A/D converter. 
Values for res are 8 10 and 12. 
Default resolution is 10 bits but you can change it to 8 or 12 bits then you have this scale value:

• 8: 0 to 255 
• 10: 0 to 1023 
• 12: 0 to 4096 
If you don't use this function, A/D resolution is ten bits for default.