Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
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:
You can find these components at the following links:
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:
irSensorPin
.setup()
function, we initialize the serial communication and set the irSensorPin
as an input.loop()
function, we read the state of the IR sensor using digitalRead()
and store it in irSensorState
.Serial.println()
.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:
HIGH
, indicating the presence of an object, the message "Object detected!" is printed to the serial monitor.LOW
, indicating no object is detected, the message "No object detected." is printed.