Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use ir sensor : Examples, Pinouts, and Specs

Image of ir sensor Design with ir sensor in Cirkit Designer

Introduction

An infrared (IR) sensor, manufactured by Arduino (Part ID: G), is a versatile electronic component designed to detect infrared radiation. It is commonly used in applications such as motion detection, proximity sensing, and remote control systems. The sensor operates by emitting or detecting IR light, making it ideal for non-contact sensing tasks.

IR sensors are widely used in robotics, home automation, and security systems due to their reliability and ease of integration into various circuits.

Explore Projects Built with ir sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of ESP32-Based Dual IR Sensor Interface: A project utilizing ir sensor  in a practical application
ESP32-Based Dual IR Sensor Interface

This circuit features an ESP32 microcontroller connected to two IR sensors. The IR sensors are interfaced with the ESP32 via digital input pins D14 and D13, allowing the microcontroller to detect and process signals from the sensors. Both sensors are powered by the ESP32's 3.3V output and share a common ground connection with the microcontroller.

Open Project in Cirkit Designer
Image of Arduino UNO IR Sensor Motion Detector: A project utilizing ir sensor  in a practical application
Arduino UNO IR Sensor Motion Detector

This circuit consists of an IR sensor connected to an Arduino UNO. The IR sensor's output is connected to digital pin D2 of the Arduino, while its power and ground pins are connected to the 5V and GND pins of the Arduino, respectively. The Arduino is programmed to read the sensor data and can be used for applications such as object detection or proximity sensing.

Open Project in Cirkit Designer

Technical Specifications

The following table outlines the key technical specifications of the Arduino IR Sensor (Part ID: G):

Parameter Value
Operating Voltage 3.3V to 5V
Operating Current 20mA (typical)
Detection Range 2 cm to 30 cm (adjustable)
Output Signal Digital (High/Low)
Wavelength Sensitivity 760 nm to 1100 nm (infrared range)
Response Time < 2 ms
Operating Temperature -25°C to 85°C

Pin Configuration

The IR sensor typically has three pins. The table below describes each pin:

Pin Name Description
1 VCC Power supply pin (3.3V to 5V)
2 GND Ground connection
3 OUT Digital output pin (High when no object detected,
Low when an object is detected)

Usage Instructions

Connecting the IR Sensor

To use the IR sensor in a circuit:

  1. Connect the VCC pin to the 5V output of your microcontroller or power supply.
  2. Connect the GND pin to the ground of your circuit.
  3. Connect the OUT pin to a digital input pin on your microcontroller (e.g., Arduino UNO).

Example Circuit

Below is an example of how to connect the IR sensor to an Arduino UNO:

Sample Arduino Code

The following code demonstrates how to use the IR sensor with an Arduino UNO to detect objects:

// Define the pin connected to the IR sensor's OUT pin
const int irSensorPin = 2;

// Define an LED pin for visual feedback
const int ledPin = 13;

void setup() {
  pinMode(irSensorPin, INPUT); // Set the IR sensor pin as input
  pinMode(ledPin, OUTPUT);     // Set the LED pin as output
  Serial.begin(9600);          // Initialize serial communication
}

void loop() {
  int sensorValue = digitalRead(irSensorPin); // Read the sensor's output

  if (sensorValue == LOW) {
    // Object detected
    digitalWrite(ledPin, HIGH); // Turn on the LED
    Serial.println("Object detected!");
  } else {
    // No object detected
    digitalWrite(ledPin, LOW);  // Turn off the LED
    Serial.println("No object detected.");
  }

  delay(100); // Small delay for stability
}

Important Considerations

Troubleshooting and FAQs

Common Issues and Solutions

  1. The sensor is not detecting objects:

    • Verify the wiring connections (VCC, GND, and OUT).
    • Ensure the sensor is powered with the correct voltage (3.3V to 5V).
    • Check for obstructions on the sensor's IR emitter or receiver.
  2. False detections or inconsistent readings:

    • Avoid using the sensor in areas with strong IR sources (e.g., sunlight, heat lamps).
    • Adjust the detection range using the onboard potentiometer.
  3. Output signal is always HIGH or LOW:

    • Confirm that the sensor is functioning by testing it with a multimeter.
    • Ensure the object is within the sensor's detection range.

FAQs

Q: Can the IR sensor detect transparent objects?
A: IR sensors may have difficulty detecting transparent or highly reflective objects. For such cases, consider using a different type of sensor, such as an ultrasonic sensor.

Q: How do I increase the detection range?
A: If the sensor has an onboard potentiometer, you can adjust it to increase or decrease the detection range. However, note that increasing the range may reduce accuracy.

Q: Can I use the IR sensor with a 3.3V microcontroller?
A: Yes, the IR sensor operates within a voltage range of 3.3V to 5V, making it compatible with 3.3V microcontrollers.

By following this documentation, you can effectively integrate the Arduino IR Sensor (Part ID: G) into your projects for reliable infrared detection.