Need help with making a password circuit + writing code

Ok, but how do I do that check for a button state change?
This is my serial output:
1
2
3
4
3
2
1
(it just displays the number of the button when it "gets HIGH" (pressed).