Arduino UNO As A MIDI Keyboard

You're not using the correct pins for the NoteButtons, you should be using M1.pin(0) etc.