Xiao DAC/ADC code example


I got this XIAO module not long ago, and I am still learning about this board and using Arduino

I want to implemente a ADC and a DAC in XIAO module using Arduino IDE, but I am having trouble finding the lib resource and function descriptions. I am actually not sure how to implement these two

For ADC I am considering just using analogread() function, and DAC, I am thinking is to make a array size of 1024 and write it to the GPIO. However, I think there might be a standard/better way to implement these two or is there any driver lib that support this ?

Thanks in advance

I think this two function will meet your need.

AnalogRead for ADCs, but AnalogWrite isn’t a DAC library. It’s for PWMs.
You can’t produce a differentiable/smooth function from a PWM without adding extra hardware. @JB_12 is asking what libraries are needed to use the dedicated DAC port on the XIAO (maybe AnalogWrite has functionality not mentioned in the official spec?). The online support for this board is abysmal, but if I can really get a proper DAC on a $5 board, it’s worth the headache.

Sorry, AnalogWrite meets the need for beginners.If you want a smooth DAC, this Arduino Library should meet your needs. @calhounpaul
https://github.com/ocrdu/Arduino_SAMD21_Audio_Player @calhounpaul

Thanks! That works great!