Variable to identify which type of Xiao we are on?

Hi !
I made a code which works perfectly on the regular Xiao, but it seems Xiao RP2040 uses Serial1 instead of Serial, so I’m trying to make my code compatible with both versions

I tested with a user variable I set to “true”, but I think there is perhaps a way to use a pre-defined variable which exists when we compile for RP2040 and which doesn’t exist if we compile for regular Xiao.

I found ARDUINO_ARCH_RP2040, does it work for RP2040 Xiao ?

Thanks

Certainly! To make your code compatible with both the regular Xiao and Xiao RP2040, you can utilize the ARDUINO_ARCH_RP2040 pre-defined macro.

By using conditional compilation directives, you can differentiate between the two platforms and initialize the appropriate serial port accordingly. For example, use Serial for the regular Xiao and Serial1 for the Xiao RP2040. This approach ensures that your code works seamlessly on both versions, allowing you to leverage the unique features of each board without the need for extensive code modifications.