Create a 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.
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.
- 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
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.
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w
This Post / Project can also be found using search terms:
- arduino ir sensor alarm