Daniel Ramsgard
Published

IAADL: An Infrared-Activated Automatic Door Lock

Build an infrared-activated automatic door lock for cheap with an Arduino Uno and an Infrared transmitter.

BeginnerFull instructions provided1 hour128
IAADL: An Infrared-Activated Automatic Door Lock

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Bipolar - RF Transistor, NPN
Bipolar - RF Transistor, NPN
×4
DC Motor, Miniature
DC Motor, Miniature
×1
Infrared Receiver, 38 kHz
Infrared Receiver, 38 kHz
×1
Through Hole Resistor, 10 ohm
Through Hole Resistor, 10 ohm
×5
9V battery (generic)
9V battery (generic)
×1
Battery Contact, PP3 (9V)
Battery Contact, PP3 (9V)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
latch door lock
×1
infrared remote control
×1
Through Hole Resistor, 2.1 kohm
Through Hole Resistor, 2.1 kohm
×1
threaded nut
×1

Story

Read more

Schematics

Circuit Schematic

Code

IAADL Circuit

Arduino
//Code produced by Daniel Ramsgard using the IRremote library by Shirriff
#include <IRremote.h>
 IRrecv irrecv(A5);
int dividend = 2;
int signalValue = 1799;
//Set infrared receiving pin, that's connected to receiver output lead, to analog pin 5
//Initialize variables for a dividend variable and an expected IR signal value

void setup() {
  //Set pins as outputs for transistors, and initialize IR receiver
  //Set serial port baud rate to 9600
  Serial.begin(9600);
  IrReceiver.enableIRIn();
  pinMode(5, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);
}

void loop() {
 //Make the divisor varibale constant: unable to be changed via arithmetic
 const int divisor = 2;
 //If there is a signal, data gets assigned to "expectedSignal"
  if (IrReceiver.decode()){
     int expectedSignal = IrReceiver.decodedIRData.decodedRawData; 
     //If the signal matches the expected signal, motor spins
     if((signalValue == expectedSignal) && (dividend%divisor == 0)){
      analogWrite(6, 200);
      analogWrite(9, 200);
      delay(3000);
      analogWrite(6, 0);
      analogWrite(9, 0);
    }
    //If the signal value matches the expected signal, motor spins in the opposite direction
     if((signalValue == expectedSignal) && (dividend%divisor == 1)){
      analogWrite(5, 200);
      analogWrite(10, 200);
      delay(3000);
      analogWrite(5, 0);
      analogWrite(10, 0);
    }
    //dividend is incremented. This allows only one of the if blocks to be valid
    dividend++;

    IrReceiver.resume();   //The infrared receiver is resumed for listening
  }
}

Credits

Daniel Ramsgard

Daniel Ramsgard

18 projects • 15 followers
I'm a freshman at UNC-Chapel Hill from NY & love Arduino, electronics, PCB design, and smart devices. www.github.com/DanielRamsgard
Thanks to Shirriff.

Comments