0% found this document useful (0 votes)
582 views

Arduino Door Lock Using 4x4 Keypad and Servo Motor

This document describes an Arduino door lock project using a 4x4 keypad and servo motor. It includes code to define the keypad pins and buttons, compare input to a password string, and control a servo motor to lock and unlock a door based on the password being entered correctly. The servo motor is attached to pin 11 and moves to positions 11 degrees for locked and 90 degrees for unlocked. Red and green LEDs also indicate the locked/unlocked status.

Uploaded by

KshitijKumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
582 views

Arduino Door Lock Using 4x4 Keypad and Servo Motor

This document describes an Arduino door lock project using a 4x4 keypad and servo motor. It includes code to define the keypad pins and buttons, compare input to a password string, and control a servo motor to lock and unlock a door based on the password being entered correctly. The servo motor is attached to pin 11 and moves to positions 11 degrees for locked and 90 degrees for unlocked. Red and green LEDs also indicate the locked/unlocked status.

Uploaded by

KshitijKumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

4/23/2018 Arduino Door Lock Using 4x4 Keypad and Servo Motor.

txt

// MakeloGy ( subscribe )

// - Arduino Door Lock Using 4x4 Keypad and Servo Motor

#include <Keypad.h>
#include <Servo.h>

Servo servo_Motor;
char* password = "123";
int position = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[ROWS] = { 8, 7, 6, 9 };
byte colPins[COLS] = { 5, 4, 3, 2 };
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int redPin = 12;
int greenPin = 13;

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
servo_Motor.attach(11);
setLocked(true);
}

void loop()
{
char key = keypad.getKey();
if (key == '*' || key == '#')
{
position = 0;
setLocked(true);
}
if (key == password[position])
{
position ++;
}
if (position == 3)
{
setLocked(false);
}
delay(100);
}
void setLocked(int locked)
{
if (locked)
{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
servo_Motor.write(11);
}
else
{
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
servo_Motor.write(90);
}
}

https://www.dropbox.com/s/exst8lbodq45d4u/Arduino%20Door%20Lock%20Using%204x4%20Keypad%20and%20Servo%20Motor.txt?dl=0 1/1

You might also like