sendCommand replace 0x0249

sendCommand(CMD_PLAY_WITHFOLDER, 0x0249)

In this line of code I would like to replace the 0x0249 with a variable but after a lot of time looking I have not been able to make that work.

// random number from 10 to 50 to append to the end 0x02
randNumber = random(10, 50);
Serial.println(randNumber);
String voice = str1 + randNumber;
Serial.println(voice);

I have generated the variable but unable to get it to read int the command line. It appears to compile in when I use the voice variable but no sound from the mp3 player. When I put the 0x0249 I have sound.

Any help would be greatly appreciated.

Thanks in advance

I use the voice variable

0x0249 is not a String variable. It is an integer that happens to fit into a byte or char variable.

Use randNumber in the function call instead, if it is within the legal range.

What does that particular number do?

By the way, we advise to not use Strings with Arduino. They cause memory problems.

//led setup
int led3 = 3;
int led5 = 5;
int led6 = 6;
int led9 = 9;
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
long randNumber; // random number for voice mix
String str1 = "0x25"; // volume setting
int voice; // voice record on SD card

The variable voice I am using is a int. If I understand your answer correctly.

The variable voice I am using is a int.

Then what the h*ll is this?

String voice = str1 + randNumber;

Post ALL your code, using code tags. And please read the "How to use this forum" post, which prepares you for asking sensible questions.

jremington:
Then what the h*ll is this?

String voice = str1 + randNumber;

Post ALL your code, using code tags. And please read the "How to use this forum" post, which prepares you for asking sensible questions.

Thank you for your time. I can see my not understanding how the data is stored has irritated you. I was just trying to understand and fix the problem I was having. The profanity helps me in no way. I will withdraw the question with my apologizes for upsetting you.

//led setup
int led3 = 3;
int led5 = 5;
int led6 = 6;
int led9 = 9;
int brightness = 0;      // how bright the LED is
int fadeAmount = 5;      // how many points to fade the LED by
long randNumber;         // random number for voice mix
int volume = 0x25;    // volume setting
int voice;

@RonGoad,

We get hundreds of posts per week here asking for help. Many of those do not provide enough information so we added a post in almost every section about “HOW TO POST” in the hope that people provide all information in their first post.

After seeing dozens posts with missing information week in week out, people that are trying to help get anoyed.
Don’t take it personal, just provide as much info as you can. Then you are helping us to help you.

robtillaart:
@RonGoad,

We get hundreds of posts per week here asking for help. Many of those do not provide enough information so we added a post in almost every section about "HOW TO POST" in the hope that people provide all information in their first post.

After seeing dozens posts with missing information week in week out, people that are trying to help get anoyed.
Don't take it personal, just provide as much info as you can. Then you are helping us to help you.

Appreciate your time I am not sure what data that is needed when I become smarter about how to ask a question I will try to return. What I have works would like to add the variable to get more random response from the MP3 player. There are other ways to do it just not as effective.

Thanks for you time sir

(deleted)