Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

IR Sensor Module - An Introduction to Infrared Sensors

Importance and Utility of IR Sensor Module

Infrared (IR) sensors are widely used in various applications, including robotics, automation, security systems, and remote controls. These sensors detect and measure infrared radiation, which is invisible to the human eye but emitted by all objects with a temperature above absolute zero. IR sensors are essential for detecting and measuring heat, motion, and proximity, making them versatile tools in electronic projects.

Project: Building an IR Sensor Module

In this project, we will build a simple IR sensor module using an Arduino board. The module will be able to detect the presence of an object within a certain range and provide an output signal indicating the detection.

List of Components:

  • Arduino Uno board x1
  • IR sensor module x1
  • Jumper wires x5
  • Breadboard x1

You can find these components at the following links:

  • Arduino Uno: [link]
  • IR sensor module: [link]
  • Jumper wires: [link]
  • Breadboard: [link]

Examples:

Example 1: Basic IR Sensor Module Setup

// Pin connected to the output of IR sensor module
int irSensorPin = 2;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Set the IR sensor pin as input
  pinMode(irSensorPin, INPUT);
}

void loop() {
  // Read the state of the IR sensor
  int irSensorState = digitalRead(irSensorPin);

  // Print the sensor state to the serial monitor
  Serial.println(irSensorState);

  // Delay for 500 milliseconds
  delay(500);
}

Explanation:

  • We define the pin connected to the output of the IR sensor module as irSensorPin.
  • In the setup() function, we initialize the serial communication and set the irSensorPin as an input.
  • In the loop() function, we read the state of the IR sensor using digitalRead() and store it in irSensorState.
  • We then print the sensor state to the serial monitor using Serial.println().
  • Finally, we add a delay of 500 milliseconds before repeating the loop.

Example 2: Object Detection with IR Sensor Module

// Pin connected to the output of IR sensor module
int irSensorPin = 2;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Set the IR sensor pin as input
  pinMode(irSensorPin, INPUT);
}

void loop() {
  // Read the state of the IR sensor
  int irSensorState = digitalRead(irSensorPin);

  // Check if an object is detected
  if (irSensorState == HIGH) {
    Serial.println("Object detected!");
  } else {
    Serial.println("No object detected.");
  }

  // Delay for 500 milliseconds
  delay(500);
}

Explanation:

  • This example builds upon the previous one by adding a condition to check if an object is detected.
  • If the IR sensor state is HIGH, indicating the presence of an object, the message "Object detected!" is printed to the serial monitor.
  • If the IR sensor state is LOW, indicating no object is detected, the message "No object detected." is printed.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.