PaulS:
If val is 380, what will that function return? According to my fat-fingered calculations, 380 is less than minButtonVal[0], so the function should return 0, indicating that the 0th switch was pressed. But, 0 means no switch was pressed.Why doesn't -1 mean that no switch was pressed?
In the OP, there is no 0 button. They start at 1, so 0 can be used to mean "no button". BulldogLowell's function does the same. For a val of 380, both of our functions return 0. The test inside my mp3Bank makes sure there is a valid button number:
if (button > 0) {
-1 could be used, but I was just matching the OP.