Infrared Detector

Z2M Part: EMS-00013-A

Detect obstacles using IR transmitter and receiver.

Circuit Diagram
Circuit diagram for Infrared Detector
Wire Connections & Pin Configuration

Wire Color Connections:

Yellow → Digital Pin 2 to IR sensor OUT (or Pin 4 per code)
Red → 5V to IR sensor VCC
Black → GND to IR sensor GND

Pin Configuration:

Arduino Digital Pin 2 → IR sensor OUT
Arduino 5V → IR sensor VCC
Arduino GND → IR sensor GND
Arduino Code
Edit
int sensorinput = 4;  // Digital pin connected to IR sensor output
int ledoutput = 11;   // Pin connected to LED

void setup() {
  pinMode(ledoutput, OUTPUT);  // Set LED pin as output
  pinMode(sensorinput, INPUT); // Set sensor pin as input
  Serial.begin(9600);          // Initialize Serial Monitor
}

void loop() {
  int value = digitalRead(sensorinput);  // Read sensor output
  Serial.println(value);                 // Print sensor value to Serial Monitor

  if (value == LOW) {                    // If sensor detects object (LOW signal)
    digitalWrite(ledoutput, HIGH);       // Turn ON LED
    delay(100);                          // Small delay for visibility
  } else {
    digitalWrite(ledoutput, LOW);        // Turn OFF LED
  }
}

Instruction Details

Wiring: Connect IR sensor VCC to 5V, GND to GND, OUT to Digital Pin 4. Connect LED anode to Digital Pin 11 via 220Ω, cathode to GND.
Library: Not required (built-in).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: LED turns ON when obstacle detected. Open Serial Monitor at 9600 baud to see digital values. Place object in front of sensor to test.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • IR Obstacle Sensor Module (FC-51 or similar)
  • LED
  • 220Ω Resistor
  • Breadboard
  • Jumper Wires

Category: Sensors