Mirko Pavleski
Published © GPL3+

Arduino Door Lock with Smartphone Flashlight Login

A simple project where access is made possible in a very unusual way with the help of a flashlight from a smartphone

BeginnerFull instructions provided3 hours747
Arduino Door Lock with Smartphone Flashlight Login

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
LDR module
×1
IRF730 Mosfet
×1
MINI RELAY DPDT NA-12W-K 12VDC 8PIN 2POLES 1A
TaydaElectronics MINI RELAY DPDT NA-12W-K 12VDC 8PIN 2POLES 1A
×1
LED (generic)
LED (generic)
×2
Resistors
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Schematic

...

Code

Arduino code

C/C++
...
#define Solenoid 12
#define ldr 8
int Buzzer = 4;
int GreenLed = 6;
int RedLed = 11;
int val;
int val2;
String duration;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(ldr, INPUT_PULLUP);
  pinMode(Solenoid, OUTPUT);
  pinMode(GreenLed, OUTPUT);
  pinMode(RedLed, OUTPUT);
  digitalWrite(RedLed, HIGH);
}

  void OpenDoor(){             //Lock opening function open for 3s
 
  digitalWrite(Solenoid,HIGH);
  tone(Buzzer, 500);
  digitalWrite(RedLed, LOW);
  digitalWrite(GreenLed, HIGH);
  
  delay(3000);
  digitalWrite(Solenoid,LOW);
  noTone(Buzzer);
  digitalWrite(RedLed, HIGH);
  digitalWrite(GreenLed, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  int val = digitalRead(ldr);
  while(val == 0)
  {
    int val2 = digitalRead(ldr);
    duration += val2;
 
    if(duration == "0001")
    {

      OpenDoor();
    }
  
    if(val2 == 1)
    {
      duration = "";
      break;
    }


    delay(200);
  }

}

Credits

Mirko Pavleski

Mirko Pavleski

140 projects • 1239 followers

Comments