Skip to main content

Parking Gate with Password Protected Entry | ElectroMech Lab | Arduino

Hello Friends,
This project is for password/PIN protected Parking gate. This is very interesting project. I hope you like it.

Material:

Arduino UNO - 1 No.
Servo Motor - 1 No.
IR Sensor - 1 No.
4x4 Keypad - 1 No.
9V Battery - 1 No.
Toy Car - As per your wish.
10 Kohm Resistor - 1 No.


Sketch:

 // This code is for password/PIN protected Parking Gate.
#include <Keypad.h>
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

int exitSensor= 10;   // pin 10 is connected to out sensor, when vehicle is passed after toll crossing





//******************************************************** keypad initialisation  ************************************

char* password = "1245"; // if this is changed then modification is needed in loop section validating the keys
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
      {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
  };

byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
int position = 0;

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );





//******************************************************** Setup ************************************

void setup(){
    Serial.begin(9600);               // communication is initialised
    pinMode(13, OUTPUT);              // Sets the digital pin as output, if used, optional.
    pinMode(exitSensor,INPUT); // exitSensor is set a Input, extra resistor are required, it can be used as high or low.
    myservo.attach(12);               // servo is attached this pin 12
}





//******************************************************** Loop ************************************
void loop(){
  int exitStatus = digitalRead(exitSensor); // it senses the exit sensor after crossing the toll gate
 char key = keypad.getKey();
 if(key == '*' || key == '0' || key == '3' || key == '6' || key == '7' || key == '8' || key == '9' || key == 'A' || key == 'B' || key == 'C' || key == 'D' || key == '#' || exitStatus == 1) // if these keys are pressed and exitStatus goes low then it will close the gate
{
position = 0;           //if wrong key is pressed then position (variable will be zero and password count will start again
myservo.write(175);     // if wrong key is pressed then gate will close
}

if(key == password[position]) 
{
position ++; // if correct key is pressed then position is increased

}
if(position == 4)  // when position is equal to 4 means, correct digits are pressed then next command is executed
{
myservo.write(90);  // when position is equal to 4 means, then motor moves to the angle 90, however it can be changed
}
  
delay(10);
}



// ******************   end of the sketch **********************

Comments

Popular posts from this blog

How to Make Automatic Room Light Controller Without Microcontroller

You must have noticed in some offices or hotels, when nobody is in gallery or washroom, the light remains OFF but when somebody enters the place, light switches ON automatically. In this post I am going to teach you how to make this circuit. Before going ahead I would like to tell you that this is VERY EASY circuit. For this circuit the material we need is… PIR Motion sensor General Purpose PCB - 5x5 cm. Transistor 2222N – 1 No. Relay 5V – 1 No. 1K/0.250W – 2 Nos. 10K/0.250W – 1 No. IN4007 – 2 Nos. LED 3mm – 1 No. Connector – 4 Nos. Few wires. Relay Circuit Concept : We can use any relay of 12V, 24V, 5V etc. but we have to consider power supply or battery we will use. Since 5V power supply is easily available and 9V battery can also be used for 5V output (after using 7805 regulator if needed). So I am using 5V relay. PIR sensor has three terminals, One for 5Vdc Second for Gnd (0V). Third for ...

AND Logic Gate by Transistors

Creating an AND gate using transistors is a fundamental exercise in digital electronics. In this post, I will guide you through the process of building an AND gate with transistors, explaining each step in detail.   What is an AND Gate? An AND gate is a basic digital logic gate that outputs TRUE or HIGH (1) only when all its inputs are true or high. If any of the inputs are false or low (0), the output is false or low (0). The truth table for a two-input AND gate is as follows: Input A Input B Output 0 0 0 0 1 0 1 0 0 1 1 1   Components Needed To build an AND gate, you will need the following components: NPN Transistors: BC547 (2 Nos.); Q1, Q2. Resistors : 10K (2 Nos) - R1, R2. Resistors : 1K (1 No) - R3. LED: 5mm Red (1 No) – L1, for output indication. Switches: ...

Difference between Bootloader & Firmware Update

Updating the bootloader and updating the firmware in a microcontroller are two distinct processes, each serving different purposes and involving different steps. Here's a breakdown of the differences: Bootloader Update Purpose : The bootloader is a small program that runs before the main application. It is responsible for initializing the microcontroller and loading the main application firmware. Updating the bootloader might be necessary to add new features, fix bugs, or improve the boot process.   Process : 1.       Enter Bootloader Mode : To update the bootloader, the microcontroller must be put into a special mode. This often involves setting specific pins, pressing buttons, or using a specific command through an existing firmware interface. 2.      Communication Interface : The bootloader update typically uses a specific communication interface such as UART, SPI, I2C, or USB. 3.   ...