top of page
Search

How to Make Remote Door Lock




Circuit:



Download Code click.....


const int irPin = 4;

const int Relay1 = 2;

const int led = 3;


boolean Relay1State = false;


void setup() {

//Serial.begin(115200);

pinMode(irPin, INPUT);

pinMode(Relay1, OUTPUT);

pinMode(led, OUTPUT);

digitalWrite(Relay1, HIGH);

}


void loop() {

int key = getIrKey();


if(key == 3563 && 3425 && 3564 && 2343){

Relay1State = !Relay1State;

if(Relay1State == true){

digitalWrite(Relay1, LOW);

delay(1000);

digitalWrite(Relay1, HIGH);

delay(1000);

}

else

digitalWrite(led, HIGH);

delay(100);

digitalWrite(led, HIGH);

delay(100);

digitalWrite(led, HIGH);

delay(100);

digitalWrite(led, HIGH);

delay(100);

}


}


int getIrKey(){

int len = pulseIn(irPin,LOW);

int key, temp;

key = 0;

//Serial.print("len=");

//Serial.println(len);

if(len > 5000) {

for(int i=1;i<=32;i++){

temp = pulseIn(irPin,HIGH);

if(temp > 1000)

key = key + (1<<(i-17));

}

}

if(key < 0 )

key = -key;

//if(key)

//Serial.println(key);


delay(250);

return key;

}

334 views0 comments

Recent Posts

See All
bottom of page