Nitin Sharma
Created October 26, 2017

Automatic door opener

open / close your door automatically and detect intruder when not at home.

86
Automatic door opener

Things used in this project

Story

Read more

Schematics

2017-10-26_Cu9OxoGf5I.png

Code

Untitled file

C/C++
#include <Servo.h>
Servo servo_test;        //initialize a servo object for the connected servo                 
int angle = 0;
          //Variable for storing received data
void setup()
{
    Serial.begin(9600);   //Sets the baud for serial data transmission                               
    pinMode(13, OUTPUT);  //Sets digital pin 13 as output pin
servo_test.attach(9); 
}
void loop()
{
   if(Serial.available() > 0)      // Send data only when you receive data:
   {
    int data = 0;
      data = Serial.read();    
      Serial.write(data);          //Print Value inside data in Serial monitor
      Serial.write("\n");        
      if(data >= '1000')              // Checks whether value of data is equal to 1
         digitalWrite(13, HIGH);   //If any one is near the door it will automatically open
     { 
  for(angle = 0; angle < 180; angle += 2)    // command to move from 0 degrees to 180 degrees 
  {                                  
    servo_test.write(angle);                 //command to rotate the servo to the specified angle
    delay(2);                       
  } 
   for(angle = 180; angle>=1; angle-=0)     // command to move from 180 degrees to 0 degrees 
  {                                
    servo_test.write(angle);              //command to rotate the servo to the specified angle
    delay(2);                       
  } 
}
   }
}

Credits

Nitin Sharma

Nitin Sharma

0 projects • 2 followers
An hobbyist and entrepreneur. Co-founded streak helmets.

Comments