Arun
Published © GPL3+

Smart BT Door Lock (Simple Arduino)

This is a simple project made with Arduino Uno R3. The aim is to control a door lock without keys but using a smart phone instead.

BeginnerShowcase (no instructions)2 hours15,563
Smart BT Door Lock (Simple Arduino)

Things used in this project

Schematics

connection

After connecting the Bluetooth module, connect the servo:

SERVO CONNECTION
1. Orange --- Arduino Pin 2
2. Red --- Arduino 5v
3. Brown --- Arduino GND

Code

smart lock

Arduino
download it!
#include <Servo.h>
/*0-lock position,170-open position*/
Servo lock;

void setup() 
{
 lock.attach(2);
 Serial.begin(9600);
 lock.write(0);
 delay(500);
 }
void loop() 
{
  int i;
  int s=1;
  start:
  int a;
  if(Serial.available()>0)
  {
    a=Serial.read();
    if(a==9&&(s==1))
    {
     for(i=0;i<=170;i++)
     {
       lock.write(i);
       delay(7);
     }
     Serial.print("OPEN");
     s=0;
    }
    if((s==0)&&(a==5))
    {
      for(i=170;i>=0;i--)
    {
       lock.write(i);
       delay(7);
    }
    Serial.print("LOCKED");
    s=1;
      }
  }
  goto start;
}

Credits

Arun

Arun

1 project • 10 followers

Comments