Building a safety lock using a keypad
We now know how to read input from a keypad and how to control a servomotor. We are going to use this knowledge to build a safety lock that opens when the correct passcode has been entered through the keypad. As we wrote libraries to control the servo and read data from the keypad, we only need to write the logic to check a passcode and light up LEDs. We are going to let the red LED blink each time a key is being pressed. When we enter a wrong passcode, we light up the red LED for 3 seconds. When we enter the correct passcode, we light up the green LED for 3 seconds and trigger the servomotor.
Building the circuit
We are going to reuse the circuits we built in the previous sections of this chapter. As we already have a servo and the keypad wired, we just have to add the LEDs and the resistors.
To build the final circuit, follow these steps:
- Connect a GND port from the Arduino Uno with the GND lane on the power bus.
- Place a...