roshan-baig
Published © CERN-OHL

Arduino combination lock

This is an arduino UNO combination lock.

IntermediateFull instructions provided1,515
Arduino combination lock

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DIP / SIP Switch, 6 Circuits
DIP / SIP Switch, 6 Circuits
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1
Through Hole Resistor, 220 kohm
Through Hole Resistor, 220 kohm
×1
Through Hole Resistor, 1 kohm
Through Hole Resistor, 1 kohm
×6
Trimmer Potentiometer, 10 kohm
Trimmer Potentiometer, 10 kohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

circuit diagram

Code

code

C/C++
// include the library code:
#include <LiquidCrystal.h>
#include <Servo.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = A0, d5 = A1, d6 = A4, d7 = A2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int switch1 = 2;
int switch2 = 3;
int switch3 = 4;
int switch4 = 5;
int switch5 = 1;
int switch6 = 0;

Servo door;

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  //declare inputs
  pinMode(switch1, INPUT);
  pinMode(switch2, INPUT);
  pinMode(switch3, INPUT);
  pinMode(switch4, INPUT);
  pinMode(switch5, INPUT);
  pinMode(switch6, INPUT);
  // set servo motor
  door.attach(13);
  door.write(90);
}

void loop() {
  switch1 = digitalRead(2);
  switch2 = digitalRead(3);
  switch3 = digitalRead(4);
  switch4 = digitalRead(5);
  switch6 = digitalRead(1);
  if(switch1 && switch4 && switch6 == HIGH)
  {
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.write("Door not lock");
    door.write(180);
    delay(5000);
    door.write(90);
  } else
  {
    lcd.clear();
    door.write(90);
    lcd.write("Door locked");
  }for(int i = 0; i <= 3; i++)
  {
    delay(5000);
   if(switch1 != HIGH && switch4 != HIGH && switch6 != HIGH)
   {
     lcd.clear();
     lcd.write("Wait for 5 minutes");
     delay(300000);
   }
  }
}

Credits

roshan-baig
5 projects • 7 followers

Comments