Arduino Door Lock with Smartphone Flashlight Login (Li-Fi project)
This time I will describe to you a simple project where access is made possible in a very unusual way with the help of a flashlight from a smartphone.
There are many different arduino door lock projects, where the access method is using a keyboard, RFID card, biometric device, WiFi, Bluetooth, etc... This time I will describe to you a project where access is made possible in a very unusual way with the help of a flashlight from a smartphone.
Materials:
4pin Photoresistor, LDR Module
Arduino Nano
Relay SPDT, 12 Volts
RGB led diode
Power MOSFET IRF740
Circuit:
code arduino :
#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);
}
}