Lock – Week 4

The goal was to set a combination that lights the green light and closes the red one.
I used 2 buttons (a red one and a blue one), two led lights (green and red) and 4 resistors (2 ok 220Ohm and 2 of 10KOhm).
The combination is red>red>blue>red>red.

Each time a red button is pressed the counter adds up, when it get to five the lock is open. To avoid that pressing only the red button unlocks the lock, when pressing the red button with a counter of 2, the counter goes back to 0. The blue button ads 3 to the counter only if the counter is previously at 2, if not it goes back to zero. This is how the button pressed order changes the counter.

I wanted to create a code that is not specific to a given combination but I didn’t understand how to save more than the previous button state

Arduino Code here: https://drive.google.com/open?id=1_VzE4RAiEk3RPQXpj5HmoeANGIMVbdLc

Leave a Reply

Your email address will not be published. Required fields are marked *