IR sensor with Arduino, LCD, Buzzer and LED

IR proximity sensors or Infrared sensors are useful in different kinds of projects. They can be used as obstacle detection in Robotics, for parts detection in automated conveyors in industrial production line, for intrusion detection, opening and closing of doors and many others. 

Here we will show how to interface IR sensor with Arduino, LCD, Buzzer and LED. In this project when the proximity IR sensor detects presence of nearby object, the LCD will display a warning message, the Buzzer will sound alarm and the LED will turn on. Thus giving us both visual and audio signals to indicate that the sensor has detected something. The LCD, IR sensor with buzzer Arduino code is provided at the end.

 

Video Demonstration of IR sensor with Arduino, Buzzer, LCD & LED

First watch the video demo so that you know what you can expect from this tutorial. In the video, intially when there is no object in-front of the IR sensor a message "No Obstacle!" on the LCD is displayed. When hand is brought is near the IR proximity sensor, the LCD display the warning message "Warning!" "Somebody there!", and also the buzzer turns on sounding the alarm and the LED also turns on.

Interfacing IR sensor with Arduino, LCD Buzzer & LED

The wiring diagram of interfacing IR sensor with Arduino, LCD, Buzzer and LED is as shown in the figure. The IR sensor, the LED, the Buzzer are connected to the pin 2, pin 3 and pin 4 of the Arduino. The LCD is connected to the pins 13,12,11,10,9 and 8. 

Below is Circuit Simulation in Proteus Software

The above schematic diagram was realized on a breadboard and is shown below.


In the above IR proximity sensor interfacing with arduino diagram above, we have used a 10KOhm potentiometer for LCD brightness control. A separate 5V supply was used for LCD, Buzzer and LED. The ground of this supply should be connected to the ground of the Arduino.

Program Code for IR sensor with Arduino, Buzzer, LCD and LED

The following is the program code that was used in this work.

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

int irPin = 2;  // IR pin
int LED = 3; // LED pin
int buzzerPin = 4;  //Buzzer pin

int sensorOut = LOW;  // Initialize

void setup () {

// set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);

  pinMode(irPin, INPUT);
  pinMode(LED, OUTPUT);
  pinMode(buzzerPin, OUTPUT);

  Serial.begin(9600);
}

void loop() {

sensorOut = digitalRead(irPin);

  if (sensorOut == LOW)

  {

    Serial.println("No Obstacle!");
  lcd.clear();
  lcd.print("No Obstacle!");

    digitalWrite(LED, LOW);
    digitalWrite(buzzerPin, LOW);

  }

  else

  {

    Serial.println("Somebody there!");
  lcd.clear();
  lcd.print("Warning!");
  lcd.setCursor(0,1);
  lcd.print("Somebody there!");
  
    digitalWrite(LED, HIGH);
    digitalWrite(buzzerPin, HIGH);

  }

  delay(200);
}

Recommended Tutorials

16 Comments

Previous Post Next Post