Watch out when using DAC in SAMD boards!

The DAC (analogWrite to A0 in Arduino Nano 33 IoT, MKR, and Zero boards) isn’t specified to work to the extreme limits. Basically it doesn’t go below 50mV or above 3.25 volts. While the Arduino documentation doesn’t mention this, the datasheet does in section 37.11.5.

While the DAC is 10 bits, the analogWrite function reduces the resolution to 8 bits, so that the voltage resolution is about 13 mV. This means that codes 0 through 3 will act like code 4 and codes 252 through 255 will act as code 251.