Courtney PrattLydia Miller
Published

Automated Door Locking/Unlocking Device

Constantly losing your keys? Can't seem to remember whether or not you locked the door back? Then we've got the perfect device for you.

BeginnerFull instructions provided3 hours341
Automated Door Locking/Unlocking Device

Things used in this project

Hardware components

Argon
Particle Argon
×2
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×1

Software apps and online services

Maker service
IFTTT Maker service
Google Sheets
Google Sheets

Story

Read more

Schematics

Argon #1 Schematic

This is the device setup for Argon #1 to which the LED was connected. In this setup the LED is connected at pin D7; the power supply is a portable charger; and the WiFi antenna is connected to the device as normal.

Argon #2 Schematic

This is the device setup for Argon #2 to which the servo motor was connected. In this setup the motor is connected at pins A2, GND, and 3V3; the power supply is a portable charger; and the WiFi antenna is connected to the device as normal.

Code

Argon Code for Servo Motor

C/C++
Particle Web IDE Code used for Argon #2 (The device used to unlock/ lock the door using the servo motor)
Servo myservo;  // create servo object to control a servo
                

void setup()
{
  myservo.attach(A2);  // attaches the servo on the A2 pin to the servo object
  
myservo.write(10);
}

void loop()
{
Particle.subscribe("LockActivation1234", DoorUnlock);
  // Subscribe will listen for the event and, when it finds it, will run the function
  delay(1000);
}

void DoorUnlock(const char *event, const char *data)
{
  /* Particle.subscribe handlers are void functions, which means they don't return anything.
  They take two variables-- the name of your event, and any data that goes along with your event. */
  
   if (strcmp(data,"1")==0) {
    // if LED is turned on, then the servo moves to 180 degrees, waits 10 seconds and then relocks
    myservo.write(180); 
    delay(10000);
    myservo.write(10); 
    delay(1000);
    Particle.publish("TaskStatus1234","Completed");
  }
 
}

Argon Code for LED

C/C++
Particle Web IDE Code for Argon #1 (The device that was attached to the LED to indicate whether the door was locked or unlocked)
// First, let's create our "shorthand" for the pins
// led1 is D0, led2 is D7

int led1 = D0;
int led2 = D7;


// We are also going to register our Particle function

void setup()
{

   // Here's the pin configuration, same as last time
   pinMode(led1, OUTPUT);
   pinMode(led2, OUTPUT);

   // We are also going to declare a Particle.function so that we can turn the LED on and off from the cloud.
   Particle.function("led",ledToggle);
   // This is saying that when we ask the cloud for the function "led", it will employ the function ledToggle() from this app.

   // For good measure, let's also make sure both LEDs are off when we start:
   digitalWrite(led1, LOW);
   digitalWrite(led2, LOW);

}



void loop()
{ 
    Particle.subscribe("TaskStatus1234",LightOff);
delay(1000);
 
}
 
void LightOff(const char *event, const char *data)

{
  /* Particle.subscribe handlers are void functions, which means they don't return anything.
  They take two variables-- the name of your event, and any data that goes along with your event. */
  
   if (strcmp(data,"Completed")==0) {
       digitalWrite(led1,LOW);
    digitalWrite(led2,LOW);
   
   }
}

Credits

Courtney Pratt

Courtney Pratt

1 project • 1 follower
Lydia Miller

Lydia Miller

1 project • 1 follower

Comments

Add projectSign up / Login