A safe lock made with Arduino using 2 DIP switches as code setting and code entry points.

Summary

The safe lock prototype has been designed using 2 8-position DIP switches and Arduino Uno R3. 1 switch is used to set the code and the other one is used as the code entry point. As long as the codes on both switches mis-match (on any pin of any switch), the safe remains locked indicated by the red LED turned on. If the codes on both switches match then the red LED goes off and Green LED lightens indicating the code match and hence opening of the lock. When one has used the safe, the pins on the code entry switch can be again reset to lock the safe; red LED turns on and green turns off.

In real world application, 4 digit code will be very easy to break. 8 or 16 position DIP switches can be used to enhance the security but the working principle remains the same. 

This project can be used by the beginners to understand how to sense for the inputs and take actions consequently. The same type of product can also be developed with XOR gates (4001) which will be a cheaper solution.

 

Parts Used

  • Arduino Uno R3
  • Two, eight-position DIP switches
  • Two light-emitting diodes (Red and Green)
  • 8 10 kΩ resistors
  • Two 470 Ω resistors
  • Jumper Wires

How to build?

Pins 2-5 are attached to 1 DIP switch and configured as INPUTs. Corresponding pins (Pin 2 corresponds with 8, 3 with 9, 4 with 10, 5 with 11) of the other DIP switch are attached at pins 8-11 and are also configured as INPUTs. 5V power supply from the board has been used along with 10kΩ resistances as pull down resistors for each input. Pins 6 and 7 are configured as OUTPUTS and are connected to the red and green LEDs respectively through a current limiting 470Ω Resistor for each LED.

The board uses “IF” conditional and “AND” logical operators to perform the operation. “If” the inputs of the corresponding pins are at same logical state, whether HIGH or LOW, pin 7 goes HIGH and 6 goes LOW indicating the matching of codes and thus opening of the lock. If any one of the corresponding inputs mis-match, then the pin 7 goes LOW and pin 6 goes HIGH indicating the lock as closed.

Any combination of inputs (switch positions) can be used on 1 switch as the password or code. The working sketch is as follows ( .ino file also enclosed).