Arun
Published © GPL3+

IOT Smart Door (Simplest Method)

This is a simple project made with an Arduino Uno. The aim is to control a door lock without keys, and using a smartphone.

IntermediateFull instructions provided15,423
IOT Smart Door (Simplest Method)

Things used in this project

Story

Read more

Schematics

esp8266

Code

lock.ino

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

void setup() 
{
  pinMode(5,INPUT);
 lock.attach(2);
 Serial.begin(9600);
 lock.write(0);
 delay(500);
 }
void loop() 
{
  int i;
  int s=1;
  start:
  int a;
  a=digitalRead(5);/*connect digital pin 5 to ESP GPIO pin 0*/
  if((a==0)&&(s==1))
    {
     for(i=0;i<=170;i++)
     {
       lock.write(i);
       delay(7);
     }
     Serial.print("OPEN");
     s=0;
    }
    if((s==0)&&(a==0))
    {
      for(i=170;i>=0;i--)
    {
       lock.write(i);
       delay(7);
    }
    Serial.print("LOCKED");
    s=1;
      }
goto start;
}

Credits

Arun

Arun

1 project • 12 followers

Comments