Door opener

I got the Inventr Mega kit and started work on a lock for a door by using a 4x4 keypad, Uno, 20x4 LCD, and some resistors.

COMPONENTS AND SUPPLIES

1k Ohm Resistor

10

4x4 Keypad

1

InventrKits HERO

The HERO is a derivative of “Arduino UNO R3 Reference design” we just changed up a few things to make it our own. If you’re curious about what goes into our HERO board we published the open-source hardware files on our GitHub.

1

Male To Male Wire

21

Small Breadboard

1

NECESSARY TOOLS AND MACHINES

Computer

APPS AND ONLINE SERVICES

Arduino IDE

ABOUT THIS PROJECT

A while ago I started and mostly finished a project to lock and unlock my door with the use of a ESP8266, keypad, RFID, Stepper motor, and a 4×20 LCD display. I never had the time to print the shell for it and I made it for the door to a room I only recently acquired so of course I had to put this project on pause. Before I got an I2C attachment for the LCD display I used an Arduino UNO in addition to the ESP8266 so your boards would help by adding more outputs and controls compared to a normal ESP8266.

I lost the program for the esp8266 so this will only work with the keypad. Nevertheless an esp8266 and rf id can easily be integrated into it.

CODE

				
					
				
			

COMMENTS

Leave a Reply

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

//A lock by using a: //4×4 keyboard, stepper motor/driver, and a 20×4 LCD screen (the size may vary) // _______ //The Rows are={0,1,2,3} _ //The keys are={1,2,3,A}|3| // ={4,5,6,B}|2| // ={7,8,9,C}|1| // ={*,0,#,D}|0| //The Columns are=======>^| //Password = 9,7,2,5 (order does not mater) #include <LiquidCrystal.h> #include <Stepper.h> //RFID #define Receiving 0 //This allows for another board to read the card #define Transmit 1 int Star = 0; //This is used to change the UI //Stepper const int stepsPerRevolution = 2048; //stepsPerRevolution = the number of steps per rotation in this stepper (this may vary) Stepper myStepper = Stepper(stepsPerRevolution, A2, A3, A4, A5); //Make a stepper called “myStepper” and declear pins //Keypad const byte Row[] = {2,3,4,5}; //These are the pins for the Rows const byte Col[] = {7,8,12,13}; //These are the pins for the Columns //Variables float x = 0; //Incorrect numbers float y = 0; //Correct numbers float z = 0; //correct Letters int i = 0; //The amount of times password put incorrectly int q = 1024*i; //The amount of time after incorrect password is pressed = how many times you allready failed * 1024 //LCD const int rs = A1, en = A0, d4 = 6, d5 = 9, d6 = 10, d7 = 11; //These are the pins for the LCD LiquidCrystal lcd(rs, en, d4, d5, d6, d7); //These are the names for the pins //Set everything up for the begining of the program including pin mode and LCD starting screen void setup() { //Serial.begin(9600); for(int n=0; n<4; n+=1){ pinMode(Row[n], OUTPUT); } for(int n=0; n<4; n+=1){ pinMode(Col[n], INPUT); } //LCD start lcd.begin(20, 4); //LCD size Begin(); //Go to LCDpassword() //Set up Steeper myStepper.setSpeed(17); //Serial.println(“Stepper motor has been set up didn't check if it was working.”); //Serial.println(“Thats your job”); pinMode(Receiving, INPUT); pinMode(Transmit, OUTPUT); digitalWrite(Transmit, HIGH); } void LCDpassword(){ //The screen for typing the password lcd.setCursor(0, 0); lcd.print(“—Enter Password—“); lcd.setCursor(0, 1); lcd.print(“| ____ |”); lcd.setCursor(0, 2); lcd.print(“| __________ |”); lcd.setCursor(0, 3); lcd.print(“——————–“); } void IDStuff(){ //Card Reader UI lcd.setCursor(0, 0); lcd.print(“Place Card On Reader”); lcd.setCursor(0, 1); lcd.print(“| In:X |”); lcd.setCursor(0, 2); lcd.print(“| |”); lcd.setCursor(0, 3); lcd.print(“——————–“); delay(1000); lcd.setCursor(11, 1); lcd.print(“4”); Change(); delay(1000); lcd.setCursor(11, 1); lcd.print(“3”); Change(); delay(1000); lcd.setCursor(11, 1); lcd.print(“2”); Change(); delay(1000); lcd.setCursor(11, 1); lcd.print(“1”); Change(); delay(1000); lcd.setCursor(11, 1); lcd.print(“0”); } void Begin(){ lcd.setCursor(0, 0); lcd.print(“——————–“); lcd.setCursor(0, 1); lcd.print(“| Welcome, |”); lcd.setCursor(0, 2); lcd.print(“| Home |”); lcd.setCursor(0, 3); lcd.print(“——————–“); } void WiFiMode(){ //The screen for typing the password lcd.setCursor(0, 0); lcd.print(“——————–“); lcd.setCursor(0, 1); lcd.print(“| WiFi Mode- |”); lcd.setCursor(0, 2); lcd.print(“| In:X |”); lcd.setCursor(0, 3); lcd.print(“——————–“); lcd.setCursor(11, 2); lcd.print(“4”); delay(1000); Change(); lcd.setCursor(11, 2); lcd.print(“3”); delay(1000); Change(); lcd.setCursor(11, 2); lcd.print(“2”); delay(1000); Change(); lcd.setCursor(11, 2); lcd.print(“1”); delay(1000); } void Change(){ digitalWrite(Row[0], HIGH); delay(8); if(digitalRead(Col[0])==HIGH){ //…On column 0 delay(1); STAR(); //Serial.println(“*”); digitalWrite(Row[0], LOW); delay(512); Star = Star + 1; if (Star == 5){ Star = 0; } } digitalWrite(Row[0], LOW); } void ONE(){ //Print the number 1 at coordinates 5,2 on the LCD lcd.setCursor(5, 2); lcd.print(“1”); } void TWO(){ //Print the number 2 at coordinates 6,2 on the LCD lcd.setCursor(6, 2); lcd.print(“2”); } void THREE(){ //Print the number 3 at coordinates 7,2 on the LCD lcd.setCursor(7, 2); lcd.print(“3”); } void FOUR(){ //Print the number 4 at coordinates 8,2 on the LCD lcd.setCursor(8, 2); lcd.print(“4”); } void FIVE(){ //Print the number 5 at coordinates 9,2 on the LCD lcd.setCursor(9,2); lcd.print(“5”); } void SIX(){ //Print the number 6 at coordinates 10,2 on the LCD lcd.setCursor(10,2); lcd.print(“6”); } void SEVEN(){ //Print the number 7 at coordinates 11,2 on the LCD lcd.setCursor(11,2); lcd.print(“7”); } void EIGHT(){ //Print the number 8 at coordinates 12,2 on the LCD lcd.setCursor(12,2); lcd.print(“8”); } void NINE(){ //Print the number 9 at coordinates 13,2 on the LCD lcd.setCursor(13,2); lcd.print(“9”); } void ZERO(){ //Print the number 0 at coordinates 14,2 on the LCD lcd.setCursor(14,2); lcd.print(“0”); } void Akey(){ //Print the letter A at coordinates 8,1 on the LCD lcd.setCursor(8,1); lcd.print(“A”); } void Bkey(){ //Print the letter B at coordinates 9,1 on the LCD lcd.setCursor(9,1); lcd.print(“B”); } void Ckey(){ //Print the letter C at coordinates 10,1 on the LCD lcd.setCursor(10,1); lcd.print(“C”); } void Dkey(){ //Print the letter D at coordinates 11,1 on the LCD lcd.setCursor(11,1); lcd.print(“D”); } void STAR(){ //Print the * character at coordinat 1,1 on the LCD lcd.setCursor(1,1); lcd.print(“*”); } void HASH(){ //Print the # character at coordinat 18,1 on the lcd.setCursor(18,1); lcd.print(“#”); } void Row0() { //Scan the first Row… digitalWrite(Row[0], HIGH); delay(8); if(digitalRead(Col[0])==HIGH){ //…On column 0 delay(1); STAR(); //Serial.println(“*”); digitalWrite(Row[0], LOW); delay(512); Star = Star + 1; if (Star == 5){ Star = 0; } } if(digitalRead(Col[1])==HIGH){ //…On column 1 delay(1); SEVEN(); //Serial.println(“7”); digitalWrite(Row[0], LOW); delay(512); y = y+2; x = x+1; } if(digitalRead(Col[2])==HIGH){ //…On column 2 delay(1); FOUR(); //Serial.println(“4”); digitalWrite(Row[0], LOW); delay(512); x = x+1; } if(digitalRead(Col[3])==HIGH){ //…On column 3 delay(1); ONE(); //Serial.println(“1”); digitalWrite(Row[0], LOW); delay(512); x = x+1; } digitalWrite(Row[0], LOW); } void Row1() { //Scan the second Row… digitalWrite(Row[1], HIGH); delay(8); if(digitalRead(Col[0])==HIGH){ //…On column 0 delay(1); ZERO(); //Serial.println(“0”); digitalWrite(Row[1], LOW); delay(512); x = x+1; } if(digitalRead(Col[1])==HIGH){ //…On column 1 delay(1); EIGHT(); //Serial.println(“8”); digitalWrite(Row[1], LOW); delay(512); x = x+1; } if(digitalRead(Col[2])==HIGH){ //…On column 2 delay(1); FIVE(); //Serial.println(“5”); digitalWrite(Row[1], LOW); delay(512); y = y+2; x = x+1.5; } if(digitalRead(Col[3])==HIGH){ //…On column 3 delay(1); TWO(); //Serial.println(“2”); digitalWrite(Row[1], LOW); delay(512); y = y+2; x = x+1; } digitalWrite(Row[1], LOW); } void Row2() { //Scan the first Row… digitalWrite(Row[2], HIGH); delay(8); if(digitalRead(Col[0])==HIGH){ //…On column 0 delay(1); HASH(); //Reset to the starting LCD screen //Serial.println(“#”); digitalWrite(Row[2], LOW); delay(512); x = 0; y = 0; z = 0; LCDpassword(); } if(digitalRead(Col[1])==HIGH){ //…On column 1 delay(1); NINE(); //Serial.println(“9”); digitalWrite(Row[2], LOW); delay(512); y = y+2; x = x+1; } if(digitalRead(Col[2])==HIGH){ //…On column 2 delay(1); SIX(); //Serial.println(“6”); digitalWrite(Row[2], LOW); delay(512); x = x+1; } if(digitalRead(Col[3])==HIGH){ //…On column 3 delay(1); THREE(); //Serial.println(“3”); digitalWrite(Row[2], LOW); delay(512); x = x+1; } digitalWrite(Row[2], LOW); } void Row3() { //Scan the first Row… digitalWrite(Row[3], HIGH); delay(8); if(digitalRead(Col[0])==HIGH){ //…On column 0 delay(1); Dkey(); //Serial.println(“D”); digitalWrite(Row[3], LOW); delay(512); z = z+1; } if(digitalRead(Col[1])==HIGH){ //…On column 1 delay(1); Ckey(); //Serial.println(“C”); digitalWrite(Row[3], LOW); delay(512); z = z+1; } if(digitalRead(Col[2])==HIGH){ //…On column 2 delay(1); Bkey(); //Serial.println(“B”); digitalWrite(Row[3], LOW); delay(512); } if(digitalRead(Col[3])==HIGH){ //…On column 3 delay(1); Akey(); //Serial.println(“A”); digitalWrite(Row[3], LOW); delay(512); } digitalWrite(Row[3], LOW); } void CorrectPass(){ //Unlock and lock door //Serial.println(“clockwise”); myStepper.step(stepsPerRevolution); //Move stepper 2048 moves clockwise delay(10000); //allow time to close door. Change this as nessasary //Serial.println(“counter-clockwise”); myStepper.step(-stepsPerRevolution); //Move stepper 2048 moves counter-clockwise delay(5000); //Dont let people emitdiatly (dont forget to check spelling;) go behind you LCDpassword(); } void loop(){ Change(); if(Star == 2){ LCDpassword(); if (x<4){ //Scan all inputs indivisualy Row0(); Row1(); Row2(); Row3(); } if(z==2){ if(y==8){ //When the correct numbers are pressed this hapens i = 1; //Reset failed attempt timer y=0; //Reset variables x=0; //Reset variables lcd.setCursor(0, 2); lcd.print(“| CORRECT PASSWORD |”); delay(1024); Star = 0; //Go to the starting screen CorrectPass(); //go to CorrectPass() } } if(x>=4){ //If you press more then 4 digits then it resets with a timer depending on q lcd.setCursor(0, 2); lcd.print(“|INCORRECT PASSWORD|”); delay(q); x=0; //Reset variables y=0; //Reset variables i=i+2; //Increase i by 2 every time you fail } } if(Star == 3){ IDStuff(); digitalWrite(Transmit, LOW); delay(1000); digitalWrite(Transmit, HIGH); if(digitalRead(Receiving)==LOW){ //If the right card is pressed then the door unlocks lcd.print(“——————–“); lcd.setCursor(0, 1); lcd.print(“| Correct Card |”); lcd.setCursor(0, 2); lcd.print(“| Please Enter |”); lcd.setCursor(0, 3); lcd.print(“——————–“); delay(1000); CorrectPass(); i = 0; digitalWrite(Transmit, HIGH); } else{ lcd.setCursor(0, 2); lcd.print(“| INCORRECT CARD |”); q = 1024*i; delay(q); i=i+2; //Increase i by 2 every time you the wrong card is placed } } if (Star == 4){ WiFiMode(); digitalWrite(Transmit, LOW); delay(1000); digitalWrite(Transmit, HIGH); if(digitalRead(Receiving)==LOW){ //If the right card is pressed then the door unlocks lcd.print(“——————–“); lcd.setCursor(0, 1); lcd.print(“| Ulocking Door |”); lcd.setCursor(0, 2); lcd.print(“| |”); lcd.setCursor(0, 3); lcd.print(“——————–“); delay(1000); CorrectPass(); i = 0; digitalWrite(Transmit, HIGH); } } if (Star == 5){ digitalWrite(Transmit, LOW); delay(1000); digitalWrite(Transmit, HIGH); } if (Star == 0){ Begin(); Star = 1; } }
PROJECT AUTHOR
Leave a comment
TEAM MEMBERS
Christopher Diaz

Everything

TABLE OF CONTENTS
Leave a comment
Share on whatsapp
Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on pinterest
Share on email

SIMILAR PROJECTS YOU MIGHT LIKE

I cascaded four SN74HC595 shift registers to control 32 LEDs on 4 registers using 3 wires. I am adding a I2C 20×4 LCD screen to display the register and led values. I might add a standard 16×2 LCD screen to show up it is done.
A simple light meter. It’s not calibrated to any meaningful scale, but the digital readout shows a higher number the brighter is the light falling on the photoresistor.