XIAO_ESP32C6 Switching between builtin and external antenna

In addition to the on-board antenna, XIAO_ESP32C6 has a connector for an external antenna. As shown in the schematic, the antenna is switched by the FM8625H RF switch. The on-board antenna is selected by default. The external antenna can be selected with the following code.

pinMode(3, OUTPUT);    // RF switch power on
digitalWrite(3, LOW);
pinMode(14, OUTPUT);   // select external antenna
digitalWrite(14, HIGH);

The following code or a reset will enable the on-board antenna.

pinMode(14, INPUT);    // select on-board antenna
pinMode(3, INPUT);   // RF switch power off

This is the sketch I used for confirmation.
ESP32C6_XIAO_Scan_AntSelect.zip (1.1 KB)

I connected the antenna that came with the ESP32C3.
I confirmed that the antenna is switched by increasing the RSSI value.