Karl Horst
Published

Remote Control Door Lock/Unlock and Lights

I want to be able to unlock and lock my door and turn on my lights from my phone.

IntermediateFull instructions provided5 hours2,616
Remote Control Door Lock/Unlock and Lights

Things used in this project

Hardware components

Photon
Particle Photon
×1
Servos (Tower Pro MG996R)
×1
Relay (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Code

Home control

C/C++
Servo serv;

int relay1 =D3;

void setup() {
   serv.attach(D0);
   pinMode(relay1,OUTPUT);
   
    
    Particle.function("unlock", unlock);
    Particle.function("light", light);
    Particle.function("lock",lock);

}

void loop() {
}

int lock(String){
    serv.write(110);
    delay(2200);
    serv.write(98);
    
}

int unlock(String) {
    serv.write(86);
    delay(2200);
    serv.write(98);
}
   
int light(String command) {
    
    if (command=="on") {
    
    digitalWrite(relay1,LOW);
    return 1;
    }
    else if(command=="off") {
        digitalWrite(relay1,HIGH);
        return 0;
    }
}

Credits

Karl Horst

Karl Horst

1 project • 4 followers
Mechanical Engineering with concentration motorsports, student at University of North Carolina Charlotte

Comments