It's just a typo, like evanmars suggested:
if (val <= minButtonValue[ i ]) {
^
That should be "minButtonVal". Since we don't have your hardware, we can't always test. And if the program is fairly simple, I don't (or can't) always compile it. Simple misspellings is a common mistake, and after you make a few, you will spot them fairly quickly.