Password Circuit Ft. Arduino
by Fatimah Abubakkar in Circuits > Arduino
608 Views, 3 Favorites, 0 Comments
Password Circuit Ft. Arduino
Having digital security or just any type of lock on your personal items is very much necessary and important. Especially if you're someone like me, who has a sibling, some type of lock to keep those snacks safe is crucial. In this instructable, I will show you how to make a simple password circuit with a 4-digit code, using an Arduino, that will be virtually expressed on a LCD (Liquid Crystal Display) monitor.
Demonstration of Circuit
This is the video of my Arduino circuit in simulation mode. Basically how this works is that, once circuit is turned on, the LCD monitor will tell you to enter the 4-digit password. So as you can see on the first try, when the wrong password is entered, the circuit doesn't unlock and after a few seconds you're returned back to the screen where you have to enter the password. But when you do enter the right digits, the lightbulb turns on and the LCD monitor displays a message indicating that the circuit has been unlocked. To lock the circuit again, all you have to do is hold down the asterisk key for a few seconds and it will automatically return you back to the screen where you enter the 4-digit password.
Gathering the Necessary Components
To make this circuit, you'll need:
- (1) Arduino UNO R3
- (1) 16 x 2 LCD monitor
- (1) Lightbulb
- (1) 12, 5 Power Supply
- (1) 4 x 4 Keypad
- (1) Diode
- (1) Relay SPDT
- (1) NPN Transistor
- (3) Resistors - 1 kΩ, 100 kΩ, 220 Ω
- Jumper wires
The components used for the most part are pretty self explanatory. Such as:
- Arduino - used to basically control the whole circuit by being able to read the different inputs and outputs, etc.
- LCD - used as an output to display the different things such as password and status of the circuit (locked or unlocked).
- Keypad - input component used to type in the password.
- Lightbulb - used as an indicator to let you know the circuit has been unlocked.
- Jumper wires - used for the multiple connections.
- Resistors - always there to control the flow of the current.
Now the components I would like to elaborate a bit more on are:
Relay SPDT:
Variety of electronics have at least some type of relay built in it. The general purpose of a relay SPDT (Single Pole Double Throw) is to switch a low-current trigger to high current, switch a circuit on or off, reverse polarity, and many other things. Our circuit here uses a lightbulb which turns on and off depending on whether the circuit is locked or unlocked.
Diodes:
A diode is a semiconductor which acts as one-way switch for a current. The reason why we use it in our circuit is because of relay SPDT. The use of a diode in relation to a relay prevents huge voltage spikes from arising when the power supply is disconnected.
NPN Transistor:
NPN transistors are used in the applications where there is a need to sink a current. So usually a relay requires 12V from a power supply (since Arduino only outputs 5V). The transistor provides as protection in case there are cases of voltage spikes, your Arduino and the other circuits won't be affected, only the transistor.
So now that we have a basic understanding of all our components.. let's get into the fun stuff!
Wiring the Circuit (pt.1)
I decided to not use a breadboard for this circuit because majority of the components are just directly connected from pin to pin. However, you may use a breadboard if you think that's easier for you.
Tip: To make your circuit look more organized and to be able to distinguish between the different components, I suggest to use one specific colour of jumper wires for each component. (ex, green for LCD connections, yellow for light bulb connections, blue for keypad connections).
Wiring the LCD:
Step 1: Place your LCD monitor horizontally (this way the words can be displayed better). Connect 5V from the Arduino to the VCC pin on the LCD, then connect the GND (ground) from the Arduino again to the LCD's GND pin. Next, from the GND pin on the LCD, you want to connect jumper wires to contrast, read/write, and LED cathode pins. Refer to image above.
Step 2: Connect the digital pins: 2 > DB7, ~3 > DB6, 4 >DB5, ~5 > DB4, ~11 > E, 12 > RS. Refer to the image above.
Now the LCD is connected 👍.
Wiring the Circuit (pt.2)
Wiring the 4 x 4 Keypad:
Step 1: Place your keypad in an appropriate space so that it's easy to connect the wires to the pins.
Step 2: Connect the digital pins from Arduino to keypad: ~9 > Row 1, 8 > Row 2, 7 > Row 3, ~6 > Row 4. Refer to image above.
Step 3: Connect the analog pins from Arduino to keypad: A1 > Column 1, A2 > Column 2, A3 > Column 3, A4 > Column 4. Refer to image above.
Now the keypad is connected 👍.
*Note: Analog pins can be used as digital pins since "digitalRead()" (part of the code) works on all pins.
Wiring the Circuit (pt.3)
Wiring the Lightbulb With the Other Components:
Step 1: Connect terminal 1 of the lightbulb to the negative pin on the power supply. Then connect terminal 2 of the lightbulb to terminal 1 of the relay SPDT.
Step 2: Connect the positive pin of the power supply to terminal 6 of the relay. Then connect terminal 5 of the relay to the cathode of the diode. Add another jumper wire from terminal 8 of the relay to the anode of the diode.
Step 3: Next, you want to connect the collector of the transistor to the anode of the diode and then the base of the transistor to the 1 kOhm resistor. Add jumper wire from emitter to ground on the Arduino.
Step 4: Connect jumper wire from the 1 kOhm resistor to pin 13.
Step 5: Add in the 100 kOhm resistor by connecting it to one of the terminals of 1 kOhm resistor and also to the jumper wire that connects from the emitter to ground on the Arduino.
Step 6: Run the simulation and make sure everything is working just fine.
Now the lightbulb is connected with the rest of the circuit 👍.
*Note: this part of the wiring may be a bit confusing so please refer to the image above to get a better understanding.
The Code
Here's the code I used to for this password circuit. You can personalize it by changing the password and what can be displayed on the LCD monitor to whichever way you like!
To change password: char FirstTimePassword[] = {'1','2','3','4'}; < just change the numbers here.
To change the name: in the code just search my name and replace it with whatever you want it to be.
Congratulations if you made it till the end! We now have our complete password circuit. 🥳