Lilypad MP3 Coding Help

I have modified the basic trigger sketch so it plays one of 5 randomly selected files when a motion sensor is tripped. Now I would like to have 20 or 30 sound files on the micro sd card to select from. The five files on the card that work now start with numbers 1 through 5. I think I have identified the section of the code I need to change but it looks like it’s doing some kind of subtraction from a character to assign the index number. I am stuck on how to change this to accomodate 20 or 30 files.

The variable definitions are:

char filename[5][13]; I know I would need to change this to however many files I have, eg. [20][13]

int x, index;

SdFile file;

byte result;

char tempfilename[13];

This is the section of code I think I need to change, but all my attempts to change it have not worked. Any help would be appreciated. Thanks.

sd.chdir(“/”,true);

while (file.openNext(sd.vwd(),O_READ))

{

// get filename

file.getFilename(tempfilename);

index = tempfilename[0] - ‘1’;

// Copy the data to our filename array.

strcpy(filename[index],tempfilename);

file.close();

}

shazaleus, I am to new to programming to be able to be any help for you, but maybe you would be kind enough to help me I’m trying to do exactly what you have already done. Is there any way you would be willing to email me details including the code for what you have done?

Modified code is working now.