Looping for a set amount of times.

while (buttonMode == 3) {
// Do some stuff
button = 4;
}

How are you intending to exit this loop? Changing the value of button has no effect on buttonMode.