Home Forums Sparkfun MP3 Shield Library Support Forum Not all the songs are playing with the Random Play Code Reply To: Not all the songs are playing with the Random Play Code

#3544

I assume you are referring to https://gist.github.com/mpflaga/5800889

as per https://www.arduino.cc/en/Reference/Random

random(max)
random(min, max)

where the GIST example is set to 5, so I believe it outputs a range from 0-4 randomly.

In your comments I am not hearing that the order is repeatable. If that were the case you could try a different random seed and see if that changes the behavior “randomSeed(analogRead(0));” However I do believe it is a random seed, as the seed is after the MP3 and SdCard init, where the SdCard has asynchronous timing responses, sufficiently random.

I not your above line of code “rantrack = random(0);” This should only output a range of zero to zero or just zero, not good.

I will say with small ranges Random can quiet often be very repeatable, sounds like you really want pseudo random, in that it does not play repeats.  So I have updated the above GIST as not to replay repeats. It does compile, but I have not tested it. However, it is straight forward and expect it to.