The D6/D7 serial port on the XIAO RP2040 is Serial1 and you should not use Serial.
/*
* @file Voice Module.ino
* @brief
* @n [Get the module here]
* @n This example Set the voice module volume and playback
* @n [Connection and Diagram]()
*
* @copyright [DFRobot](https://www.dfrobot.com), 2016
* @copyright GNU Lesser General Public License
*
* @author [carl]([email protected])
* @version V1.0
* @date 2017-11-3
*/
unsigned char order[4] = {0xAA,0x06,0x00,0xB0};
void setup() {
//Serial.begin(115200);
Serial1.begin(9600);
volume(0x1E);//Volume settings 0x00-0x1E
}
void loop() {
play(0x01);//Play the specified audio:0x01-file0001
// Serial1.write(order,4);//order play
delay(2000);
}
void play(unsigned char Track)
{
unsigned char play[6] = {0xAA,0x07,0x02,0x00,Track,Track+0xB3};
Serial1.write(play,6);
}
void volume( unsigned char vol)
{
unsigned char volume[5] = {0xAA,0x13,0x01,vol,vol+0xBE};
Serial1.write(volume,5);
}