I am trying to write code for my Arduino Uno with Adafruit MP3 Music Maker Shield that plays a randomly selected song from an array whenever it is turned on, I have very little experience with both C++ and Arduino, but what seems like a simple task (retrieving a randomly picked string from an array) is surprisingly difficult.
Here is a sample of the code I have:
String str,song={"track001.mp3", "track002.mp3", "track003.mp3"};
str = str + song[random(0,10)];
musicPlayer.playFullFile(str);
When I try to compile I get the error: "could not convert '{"track001.mp3", "track002.mp3", "track003.mp3"}' from '' to 'String'"
I want to figure out what is causing the hour and how I can get the code I want. Any and all help would be appreciated, more code and other information can be given upon request, thanks!
Aucun commentaire:
Enregistrer un commentaire