Home Forums Sparkfun MP3 Shield Library Support Forum Triggering mp3 file over serial Reply To: Triggering mp3 file over serial


Your pasted code has an error with buffer[received] = “; but that is likely do the the pasting and not actually in your code. Your issue is about the difference in real time versus slow input. Not sure what the problem is, looks reasonable. but being a realtime problem it needs extensive debugging. I do notice that you may want to employ a delimit, such as a carriage return. i.e. 123<cr>, as to denote the ending and flag for processing the received string. This helps with lining up the messages. There are plenty of discussions out there on adding common delimits and framing. Which is the problem here.

Where as you can check out the example FilePlayer.ino. Which I created to allow larger serial messages or filenames. Per its notes.

* This sketch behaves nearly identical to MP3Shield_Library_Demo.ino, but has

* extra complicated loop() as to receive string of characters to create the

* file index. As the Serial Monitor is typically default with no CR or LF, this

* sketch uses inter character time out as to determine when a full string has

* has been entered to be processed.

This is basically what you are asking for, where as it is a bit more flexible and so being more sophisticated and complex. It uses Inter character Timeout as to delimit the requested bytes into a Frame. Or file name in this case. Allowing you to send the whole file name. Getting you longer list of files (infinite) you are able to play.