ahh..ok, looking back I see what you mean about the zero...
well in my code example..
we take the total number of 'tracks' you want to 'loop/cycle' through.. (in this instance its 5.. totalTracks = 5)
now, in most/many programming languages, they are 'zero-index' based..
meaning when they start counting.. they start at/with 0 (zero)..
In an array the first index is index[0] (ie: someArray[0] = 7, someArray[1] = 3...etc..etc..)
and in most loops, I start with 0 (zero) as my init value
example:
- Code: Select all
for(i=0; i < totalTracks; i++){
// do something while i is less than totaltracks
}
so here.. the code is looking to play 0:
0.wav
1.wav
2.wav
3.wav
4.wav
and then repeat... or go back 'down' in the count..
if you count.. that is '5' wav files... and matches the totalTracks variable we set..
I an MOT sure how many buttons or what you have in your project.. but the code is set up for only the 4 'player' buttons you mentioned..
//custom defined variables
const int prevButton = 16;
const int nextButton = 17;
const int prButton = 18; // play/resume button
const int stopButton = 12;
edit it to match your set-up if not correct...