ARDUINO Burglar Alarm Using Infrared Emitter-Detector Pair




Introduction: ARDUINO Burglar Alarm Using Infrared Emitter-Detector Pair

In this tutorial i will show you , how to make a simple Inexpensive Intrusion Detection(Burglar alarm) using an Arduino Uno board . This project uses the Infrared Emitter-Detector pair to detect intrusion and triggers an alarm as soon as the object crosses the infrared field .

** To see a Similar Project Made with an LDR click here

**To see more simple arduino projects check out my blog


  1. Arduino uno R3
  2. Breadboard
  3. Connecting wires / Jumper cables
  4. Infrared Emitter and Detector pair LED(not the sensor module)
  5. PCB mount BUZZER
  6. 1kohm Resistor
  7. 10kohm PotentiometeR

** the white LED is the Infrared emitter ,While the black is the Infrared Detector .



int dtect=8;
int sense=A0;
int buzzpin=9;
void setup()
void loop()
  int val=analogRead(sense);
void buzz(unsigned char time)


First build the circuit according to the circuit diagram provided .

Now i will explain to you how the circuit works .

  • The white Led you see in the pictures is an Infrared Emitter . You power it on like a normal LED .
  • Now if this is your first time with an IR Led , its very common that you'll mistake your LED to be spoiled as you wont find it glowing ,but that isn't the case really .
  • Infrared light is out of the visible spectrum range so even if it is glowing , you wont be able to see it with naked eyes.
  • To see if your emitter LED(White) is working properly : switch on your cell phone camera and see the LED through it , you will see that there is a purple Glow .
  • This ensures that your IR emitter (White ) is working perfectly and it is emitting light of a particular range of frequency . Now lets come to the Black LED .
  • The back LED is the IR detector. The reason that it is made black is that Black color has the highest absorption ; so it Absorbs most of the infrared light Emitted by the Emitter .
  • Now what happens if an object stands in between the Emitter and the detector ?? . OBVIOUSLY the amount of infrared radiations intercepted by the detector will now be lesser due to the obstruction .This is the catch !! .
  • When such a situation occurs , I trigger the alarm to denote Intrusion .

Now that you've got your concept right , LETS FOCUS ON THE CODE .

  • In line 10 we begin the serial communication to see the values being intercepted on the serial monitor for both the cases i.e
  • case 1.) no obstruction in the path of the emitter and the detector .
  • case 2.)obstruction in the path of the emitter and the detector .
  • for both these cases , we have to observe the values being reflected on the serial monitor , based on which we will decide for which value being exceeded we will be triggering the alarm .
  • Note that for my experiment the threshold value was set to 1005 . This might not be the case for you. Hence try to monitor the values that you are intercepting and choose your threshold accordingly .

**Well , hope I have covered all the concepts in detail regarding this project . If you face problems or if you need further detailing on any sub-topic , then please do leave me a comment .


Thank you all for watching .



    • Fix It! Contest

      Fix It! Contest
    • Tiny Home Contest

      Tiny Home Contest
    • Water Contest

      Water Contest

    23 Discussions

    How did you measure your threshold value??


    1 year ago

    Thank you so much for the time you spent putting this instructable together! My son and I put it together earlier today. We had a few minor issues, all our own (resistors in the wrong location and had to tweak the presence value for a shorter distance (we didn't use the pot). After a few min, it was all working just fine! Thank you again!!

    my buzzer continuously sounds

    my IR LEDs aren't working. can u help me?

    Can you please tell me how to learn programming arduino

    Potentiometer doesnot play a much important role. test it.

    Hi Aaryas , i haven't actually made use of the potentiometer . I have listed it as a requirement since you might have a different pair of IR-LED which work at a specific voltage level , so the Potentiometer can prove to be handy in adjusting the voltage to your IR LED .

    Hope this helps.

    0k....but if i wanna include potentiometer then where should i connect it in the circuit????

    bro can i use more than one pair of emitter detector...i want to make track of near abt 6 pair of ir...
    my project topic is "vehicle movemnt based smart street light with external light sensing"
    plz help me to get the code respect to this project...

    thnx in advance


    2 years ago

    I get the error "'buzz' was not declared in this scope" when I try run the code on Arduino.

    Any help?

    1 reply

    Can i get the screenshot of the code along with the error ? . It would be easier for me to debug that way . I guess you have either not written the code for the buzz method or perhaps you have named it something else by mistake .

    Just add a screenshot and il help you out .

    Thank you man! You helped me a lot. But I have a doubt. Why is that the amount sent by the emitter is more when there is an obstacle. For example, my emitter sends 1020 when there is an obstacle and sends 1019 when there is not obstacle?

    1 reply

    Please check if you provided Vcc to the correct leg of the IR sensor . This should solve it .

    Are you using these type of IR led Pairs or some other mounted sensor ? .

    Do attach a picture of the IR pair , if the problem persists .


    Thanks for sharing.

    One question :) Can I use a similar approach with one pair of IR emitter and detector, to measure near distances after calibration? I wanna move an object with 2 stepper motors in a closed box, and constantly know the its distance to 2 reference walls.

    1 reply

    Yep , this is very much possible with this . But i would suggest using a better precision sensor for higher accuracy . For rough distance calculation this same sketch with minor calibrations should work perfect .

    This may be a silly question but what role does the potentiometer play in this circuit?

    if you find the buzzer ringing all the time , then check the serial monitor on the arduino IDE to see the values that are being sent .

    Try calibrating the value in the program to make appropriate changes , because it depends on the type of IR-LED you used for the project .

    Also do check , the way you have connected the IR-LED's on the breadboard i.e make sure you put in the positive and negative legs appropriately .

    Hi friend. How do I monitor the values my IR sensor is detecting

    why does my buzzer sounds all the time ? whats wrong?