Reduced repeated button code

Reduced the sketch size by removing repeated code and using arrays to
store values rather unique variables.