Menu Close

Arduino Alarm using IR Pair

This tutorial of Robo India explains how tto make Alarm with Infrared Sensor

1. Introduction:

In this tutorial, we are using IR LED and Photo Diode pair with Arduino to detec intrusion within short range.

1.1 IR LED (Infrared Transmitter): It is as same as other LED we generally see, but it emits light of Infrared range 700 nanometers (nm) to 1 mm. This light is not visible through naked eyes but can be seen by camera (that is why these are also used in night vision camera).

1.2 Photo Diode: It gives response in term of change in resistance when light falls on it. That change we measure in terms of voltage.

2. Required Hardware

Following Hardware will be required to perform this sketch of IR Proximity and Color Detection.

S.No.ItemQuantity
1 Arduino UNO 1
2 Breadboard 1
3 IR Pair 1
4 Resistor 10k 1
5 Resistor 1k 1
6 Buzzer 1
7 Male to Male Jumper 9

3. Building Circuit

Make following circuit with the help of above mentioned components.

 4. Programming:

Once we are done with circuit part, here is our programme to this circuit. Every command of the following programme is explained in the comment section.

You may download this code (Arduino Sketch) from here.

//Robo India tutorial on Arduino Alarm using IR Pair
//https://www.roboindia.com/tutorials 


int photo_diode = 2; 
int analog_ip = A0;   // analog input pin Photo Diode.
int inputVal = 0;     // to store value of photo diode 
int buzzer = 9;       // digital pin for buzzer
int alarm_val = 1020;     // setting limits for makes buzzer beep 

void setup() 
{
  Serial.begin(9600);   // setup Serial Communication.                 
  pinMode(photo_diode, INPUT);
  pinMode(buzzer, OUTPUT);
  digitalWrite(photo_diode, HIGH);
  digitalWrite(buzzer, LOW);
}

void loop(){
    inputVal = analogRead(analog_ip); // Reading and storing analog input value.
    Serial.print("Input Value:");
    Serial.print(inputVal);       // Printing Analog input value of Photo Diode.
    Serial.print("\n");
    if(inputVal <= alarm_val)
    {
      digitalWrite(buzzer, HIGH);
      delay(500);
    }
    if(inputVal > alarm_val)
    {
      digitalWrite(buzzer, LOW);
      delay(500);
    }  
}

 5. Output:

Attached buzzer will get start to beep, when an obstacle is placed in the threshold range.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

Leave a Reply