Cytron MP3 shield: random play?

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Cytron MP3 shield: random play?

Postby JustKelly » Tue Dec 01, 2015 9:05 pm

Hi. I'm doing an animatronic setup and want to use your shield for the audio portion. Basically, what I need to do is this:

1) Wait a little while
2) Play a random mp3 file on the SD card
3) Repeat

It looks like mp3.PlayTrack(track #) will do what I need, but is there a way to read the SD card and see how many mp3 files there are? That way, "track #" above can be random(number of files). I can use a constant at the moment, but if we ever go back and add/subtract audio tracks, I'd have to change the constant every time, which is a pain in the neck.

Any advice would be appreciated. Thanks.
JustKelly
Freshie
 
Posts: 5
Joined: Tue Dec 01, 2015 8:45 pm

Re: Cytron MP3 shield: random play?

Postby bengchet » Wed Dec 02, 2015 1:10 am

Hi JustKelly,

You might try this out.

First, use mp3.playTrack("YourFolder",1000); or any number that you think it is impossible in that folder. It should be no response in return.
Then, use mp3.getTrackNo to get current track no, in fact it is the total number of files in that particular folder.

Hope it helps. :D
bengchet
Moderator
 
Posts: 237
Joined: Tue Aug 25, 2015 8:29 am

Re: Cytron MP3 shield: random play?

Postby JustKelly » Wed Dec 02, 2015 3:33 am

bengchet WROTE:Hi JustKelly,

You might try this out.

First, use mp3.playTrack("YourFolder",1000); or any number that you think it is impossible in that folder. It should be no response in return.
Then, use mp3.getTrackNo to get current track no, in fact it is the total number of files in that particular folder.

Hope it helps. :D


Heh! Neat trick. I'll give that a try tonight; thanks!
JustKelly
Freshie
 
Posts: 5
Joined: Tue Dec 01, 2015 8:45 pm

Re: Cytron MP3 shield: random play?

Postby JustKelly » Wed Dec 02, 2015 8:50 am

Yup, it worked just fine! That takes care of the sound F/X portion, so on to the blinky-lights. Thanks for your help!
JustKelly
Freshie
 
Posts: 5
Joined: Tue Dec 01, 2015 8:45 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 19 guests

cron