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 ...

How to drive high voltage/current load by small voltage signal from a microcontroller?

Sometimes we need to control or drive a high voltage and heavy current load by a small voltage signal. For example, if you want to control water motor with your microcontroller output. We know that microcontroller gives only 5v output which is not sufficient to drive a heavy motor. This circuit, about which this post is, is very-very useful for electronics engineer and hobbyist. So pay attention! For this circuit the material we need is… General Purpose PCB - 5x5 cm. Transistor KN 2222A (TO-92) - 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. Tools. Concept: Weak signal triggers the transistor and transistor acts as a switch for the relay. You 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)....

How to control digital output with serial monitor in Arduino

Hello Friends, in this blog we will be controlling digital output with serial monitor command. First let’s understand the working of serial monitor. Serial monitor in Arduino IDE is a tool which allows communication between the computer and Arduino board via a serial connection, normally we use USB cable for connection. What are the features of Serial Monitor? It shows the data sent from the Arduino board by using the functions like Serial.print() or Serial.println(). It allows to send text or numeric data to the Arduino board, which can be read by function like, Serial.read() or Serial.parseInt(), thereafter you can use this data for further analysis and action. We can use this tool for debugging and monitoring the function of the sketch. There is a procedure to use the serial monitor, below are the steps given. First initialize the serial communication in the sketch as given below. Normally baud rate is set 9600.  Void setup(){          Serial.begin(9600)...