/* DYSV5Wv4 * Playing Random Tracks * Mega 2560 * * Player on Serial 1 (pins 18-19) */ byte volume = 0x40; byte commandLength; byte command[6]; int checkSum = 0; void sendCommand(){ int q; for(q=0;q < commandLength;q++){ Serial1.write(command[q]); Serial.print(command[q],HEX); } Serial.println("End"); } void setup() { Serial.begin(115200); Serial1.begin(9600); Serial.println("DYSV5Wv4"); //set volume to 17 command[0] = 0xAA;//first byte says it's a command command[1] = 0x13; command[2] = 0x01; command[3] = 17;//volume checkSum = 0; for(int q=0;q<4;q++){ checkSum += command[q]; } command[4] = lowByte(checkSum);//SM check bit... low bit of the sum of all previous values commandLength = 5; sendCommand(); //play track //select random mode command[0] = 0xAA;//first byte says it's a command command[1] = 0x18; command[2] = 0x01; command[3] = 0x03;//random checkSum = 0; for(int q=0;q<4;q++){ checkSum += command[q]; } command[4] = lowByte(checkSum);//SM check bit... low bit of the sum of all previous values commandLength = 5; sendCommand(); //play track command[0] = 0xAA;//first byte says it's a command command[1] = 0x02; command[2] = 0x00; command[3] = 0xAC; commandLength = 4; sendCommand(); } void loop() { }