Arduino combination lock

Students Projects

Electronics

Arduino

Arduino combination lock

Arduino combination lock

Created By

  • Roshan Baig

    Roshan Baig

    My name is Roshan, I am 13 years old and I am in 7th standard. My hobbies are horse riding, robotics, and computer programming.

About This Project

So For my class my teacher gave me a task to make an arduino combination lock on tinkercad.This Project is arduino based project.

Components Required

  • Arduino UNO
  • Alphanumeric LCD 16 X 2
  • Dip / Sip Switch, 6 Circuits
  • SG90 Micro-servo Motor
  • Through Hole Resistor 220 kohm
  • Through Hole Resistor 1 kohm
  • Trimmer Potentiometer, 10 Kohm

Schematics

In this image all the components with the connections are given

Code Of Project

// 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);
   }
  }
}
Share