The Pattern Lock and it's Components - NoahMacDonald1/387_NM_Final GitHub Wiki
My project uses 5 buttons, and one Servo motor. 4 of them are inputs for the pattern lock, and the last is the reset code button. All 5 buttons are in input pullup mode in my code, meaning they read as logic high until they are pressed.
The Servo
The servo is a non-continuous microservo, connected to digital pin 12. To make it push and pull the lid of the box, I've tied a paperclip through a hole on the rotating head of the servo, and taped it onto my lid. The rotation of the servo opens and closes the lid.
The Buttons
As I mentioned above, 4 of my buttons are used in my box's main feature, a pattern lock. In my code, each of the buttons is matched with a value, 1-4. These values are stored in an array in the order they're entered. After 6 numbers have been entered, the code compares the input code with the stored correct code. If the pattern is correct, the box opens. If incorrect, the box will not open, and will reset to allow another attempt.
In the picture above, the left 4 buttons are the pattern lock buttons, while the one on the right is the reset button. All pins shown are accurate, meaning the pattern buttons are on pins 7-4, and the reset button is on pin 3.
Resetting the Password
I built in the ability to change the password, and it is toggled by pressing the rightmost button on the breadboard. How to use the feature is covered in the "How to Use My Project" section of the wiki home page.