Arduino Projects

Arduino password security system, Enter a Password using only one button

Password Security System Arduino Project, Description:

 

In this tutorial, you will learn how to enter a password using only one push button. This is an Arduino Password Security system. Numbers from 0 to 9 are displayed on the LCD and a push button is used to select any number. This way you don’t need a keypad matrix, which results in less wiring, reduced cost and easy programming as the one-button password entering system needs only two Arduino Pins. For demonstration purposes, I connected a 220Vac indicator lamp. This indicator lamp can only be turned ON if the correct password is entered, while the reset button is used to turn off the relay. When you enter a Wrong password the Indicator lamp will not turn ON.

Now for the 2nd attempt, you need to press the reset button. Now when you enter the correct password which is 7269…


Password security system

as you can see the indicator lamp is turned ON…Now using the reset button the relay can be turned OFF.

The Arduino Password Security system is based on Atmega328 microcontroller, the same microcontroller which is used in Arduino. To reduce the price I designed my own PCB board and sent my PCB board Gerber files to PCBway Company which is one of the top leading companies throughout the world. In part1 I explained the whole process how to generate the Gerber files and how to place an online order. The link is given in the description…

In this episode, I will cover

  1. Password Security System Circuit diagram
  2. PCB explanation
  3. Soldering
  4. Password Security System Arduino Programming and finally number
  5. Testing

Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

Mega 2560:

16X2 LCD

Atmega328 micro controller:

16Mhz crystal:

22pf capacitors:

10k Resistor:

10uf capacitors:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

DISCLAIMER:

Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


Arduino based Password Security system Circuit Diagram:

Following is the Complete Circuit diagram of the Arduino Password Security system using only one Push Button.

circuit diagram

This is the complete circuit diagram; this is a pushbutton and is used to enter a password by selecting different numbers. One side of the pushbutton is connected with the ground, while the other side is connected with pin number 2 of the Arduino…. this is also a push-button and is used to reset the password and Relay. One side of the pushbutton is connected with the ground while the other side is connected with pin number 3 of the Arduino….

This is a 16×2 LCD and will be used to display the numbers from 0 to 9…pin number 1, 5 and 16 are connected with the ground..pin number 2 and 15 are connected with 5volts. Pin number 3 is connected with the middle pin of the variable resistor. This variable resistor will be used for the LCD contrast adjustment.  The RS pin of the LCD is connected with pin number 6, the enable pin of the LCD is connected with pin number 7 of the Arduino…pins d4 to d7 which are the data pins are connected with pins 8 to 11 of the Arduino.


This is a 12v SPDT type relay. This relay has 5 pins, these are the two coil pins this is the common pin, this is the normally open pin and this is the normally closed pin. These three pins have no physical connection with the relay coil pins. This relay cannot be directly controlled using the controller… to energize the relay coil you need around 28milli amps. This is not a fixed value, this depends on the size of the relay you are using. You can easily calculate this value, first find the relay coil resistance using a digital multi meter..as it’s a 12v relay so v = 12, now using the Ohm’s law we can find the value of current needed to energize the relay coil…the type of the relay I am going to use needs 28 milliamps, so now I can use any general purpose NPN or PNP type transistor so far its collector current is greater than 28 milliamps, but it’s a good designing practice to use a larger value transistor. In my case, I will be using 2n2222 NPN transistor, as its really cheap and you can find this transistor in any electronics shop….

The collector of the 2n2222 NPN transistor is connected with the relay coil while the other side of the relay coil is connected with 12volts. The emitter of the transistor is connected with the ground. A 10k resistor is connected with the base, while the other side of the resistor is connected with pin number 13 of the Arduino. the transistor and resistor together make the relay driver circuit. This is a freewheeling diode and is used against the back emf protection.  So that’s all about the connections and now let’s discuss the PCB designing.

PCB design explanation:

Password security system

This PCB is designed in cadsoft eagle 9.1.0 version, if you want to learn how to make a schematic and PCB then watch my tutorial.

This is a double-sided PCB. The blue color represents the bottom side while the red color is the top side. All these connections are as per the circuit diagram as explained. Watch part1 for the Gerber files generation and online order placement.

Download this PCB: one button password security system

PCB boards explanation:

Password security system

These are the PCB boards which I received from the PCBway Company. As you can see the quality is really great and everything is as per the order. During the online order placement, I selected blue color, but later I decided to change it to black color. This change was only possible due to the friendly behavior of the  PCBway Company staff members. I am 100% satisfied with their work.


PCB components installation and soldering:

Password security system

First of all I  installed all the components ..as you can see maximum components are installed and now it’s time to start the soldering…

Password security system

as you can see maximum components are soldered and now only female headers and two variable resistors are balance. So I will be back after soldering the remaining components…

Password security system

As you can see all the components are soldered…

This variable resistor will be used for the lcd contrast

Password security system

this is for the lcd…

Password security system

So double check all the connections and make sure there is no short circuit before you power up the circuit. At the end connect two buttons with pin number 2 and pin number 3.

Programming:

/*
  Enter a Password using only one Push Button
  Programmer: Engr Shahzada Fahad
  Website: www.electroniclinic.com
  YouTube channel: https://www.youtube.com/c/ElectronicClinic
  Facebook Page:  https://web.facebook.com/groups/190031841821771/ 
 */
#include <LiquidCrystal.h>

#include <LiquidCrystal.h>  this a library which is specially created for the 16×2 LCD, the same library can also be used with 16×4 LCD and some other types. # means that this is a preprocessor directive and .h means that this a header file. I have a very detailed getting started tutorial on how to use a 16×2 LCD.


#define rs 6 // original 12 of arduino
#define en 7 // origional 10
#define d4 8  // original 5
#define d5 9 // 4
#define d6 10 // 3
#define d7 11 // 2
// rw of lcd is connected to ground

These are the LCD pins which I already explained in the circuit diagram.

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


// Tracks the time since last event fired
unsigned long previousMillis=0;
unsigned long int previoussecs = 0; 
unsigned long int currentsecs = 0; 
 unsigned long currentMillis = 0; 

Then I defined some variables of the type unsigned long for storing the time information.

 int secs = 0; 


 int interval= 1 ; // updated every 1 second
int epass = 2; // enter password 
int load1 = 13; // the output load/ machine, it can be a bulb, a motor etc ...
int rbutton = 3; // reset button

int Lflag = 0; // load flag

// your 4 digit password
int pdigit1 = 7; 
int pdigit2 = 2;
int pdigit3 = 6; 
int pdigit4 = 9; 

int digit1 = 0; 
int digit2 = 0; 
int digit3 = 0; 
int digit4 = 0; 

then I defined some variables of the type integer, all the variable are well commented. Still, if you have any question let me know in a comment. As you know my friends every Arduino and Mega program has at least two functions which are the void setup and void loop functions. Void means that this function is not returning any value while the empty parenthesis means that this function is not taking any arguments as the input.

void setup()
{
    Serial.begin(9600);
    // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.clear();
  lcd.print("Password  select"); 
      // Initialise the IO and ISR
pinMode(epass, INPUT_PULLUP);
pinMode(rbutton, INPUT_PULLUP);


pinMode(load1, OUTPUT); 
digitalWrite(load1, LOW);


delay(1000);

}


void loop()
{

     currentMillis = millis();
   currentsecs = currentMillis / 1000; 
    if ((unsigned long)(currentsecs - previoussecs) >= interval) 
    {
      secs = secs + 1;
      previoussecs = currentsecs;
      if (secs >= 10)
      {
        secs = 0; 
      }
 lcd.setCursor(12,1);
 lcd.print(secs); 
    }           

    password();

  if (digitalRead(rbutton) == LOW )
  {
    digitalWrite(load1, LOW); 
    Lflag == 0; 
    digit1 = 0;
    digit2 = 0 ;
    digit3 = 0; 
    digit4 = 0; 
    Serial.println("reset"); 
    lcd.setCursor(0,1);
    lcd.print("    ");

    delay(1000); 
  }
}    


 void password()
 {
 if ( (secs >= 1) && ( digitalRead(epass) == LOW) && (digit1 == 0) && (digit2 == 0) && (digit3 == 0) && (digit4 ==0))
  {
    digit1 = secs; 
    Serial.println(digit1);
    lcd.setCursor(0,1);
    lcd.print("*"); 
    delay(500); 
  }
// for digit2
   if ( (secs >= 1) && ( digitalRead(epass) == LOW) && (digit1 != 0) && (digit2 == 0) && (digit3 == 0) && (digit4 ==0))
  {
    digit2 = secs; 
    Serial.println(digit2);
    lcd.setCursor(1,1);
    lcd.print("*");
    delay(500);
  }

  // for digit3
   if ( (secs >= 1) && ( digitalRead(epass) == LOW) && (digit1 != 0) && (digit2 != 0) && (digit3 == 0) && (digit4 ==0))
  {
    digit3 = secs;
    Serial.println(digit3); 
    lcd.setCursor(2,1);
    lcd.print("*");
    delay(500);
  }

    // for digit3
   if ( (secs >= 1) && ( digitalRead(epass) == LOW) && (digit1 != 0) && (digit2 != 0) && (digit3 != 0) && (digit4 ==0))
  {
    digit4 = secs; 
    Serial.println(digit4);
    lcd.setCursor(3,1);
    lcd.print("*");
    delay(500);
  }


    if ( (pdigit1 == digit1) && ( pdigit2 == digit2) && (pdigit3 == digit3) && ( pdigit4 == digit4) && (Lflag == 0) ) 
    {
      digitalWrite(load1, HIGH);  
      Lflag == 1; 
    }
  
 }

Watch Video Tutorial:

Related Project:

Password Door Lock Security System using Arduino, Keypad, 16×2 LCD, and an Electronic Lock.

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

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

Back to top button