Create a Motion-Sensing Alarm with an Arduino and IR Sensors

Infrared (IR) sensors are normally used to measure distances, but they can also be used to detect objects. By connecting a couple of IR sensors to an Arduino, you can make an intruder alarm.
Motion-Sensing Alarm with an Arduino and IR Sensors


Infrared (IR) sensors are normally used to estimate the distance of an object, but you can also use them to detect the presence of objects. IR sensors consist of an IR transmitter and and IR receiver. The transmitter outputs pulses of infrared radiation, while at the same time, the receiver detects any reflections. If the receiver does detect a reflection, it means that there is an object at some distance in front of the sensor. If there is no reflection, then there is no object.

The IR sensor that we are using in this project is a sharp infrared IR ranger. These sensors have a small linear charge-coupled device (CCD) array that detects the angle at which the IR radiation returns to the sensor. As shown in the figure below, the sensor transmits an infrared pulse into the field, and when there is an object in front of the sensor, the pulse is reflected back to the sensor at an angle proportional to the distance that the object is away from the sensor. The sensor’s receiver detects and outputs  the angle, and using this value, you can calculate the distance.

Create a Motion-Sensing Alarm with an Arduino and IR Sensors

By connecting a couple of IR sensors to an Arduino, we can make a simple intruder alarm. We will connect the sensors to a door jamb, and by properly aligning the sensors, we can detect when someone passes through the door. When this happens, the output of the IR sensor will change, and we will detect this change by continually reading the output of the IR sensors with an Arduino. In this example, we know that an object is passing through the door when the IR sensor’s output exceeds  400. When this occurs, the Arduino will set the alarm to ON. To reset the alarm, a user can press a pushbutton.

Hardware Required

  • 2 x long-range IR sensors
  • 1 x Arduino Mega2560
  • 1 x buzzer
  • 1 x pushbutton
  • 1 x 470 ohm resistor
  • 1 x NPN transistor
  • jumper wires

Wiring Diagram

The circuit for this project is shown in the diagram below. The outputs of the two IR sensors connect to A0 and A1. The other two wires are connected to 5V and GND. A 12V buzzer is connected to pin 3 through a transistor and the pushbutton used to shut the alarm OFF connects to pin 4.


Read More: Motion-Sensing Alarm with an Arduino and IR Sensors

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top