Need help with 4 digit unlock code (Arduino UNO)

It would be much easier to use a keypad to enter a combination, and there are several tutorials on line to show you how.

To count button presses, carefully study the state change example.