0% found this document useful (0 votes)
8 views1 page

Arduino IR Sensor Guide

The document outlines a project involving an IR sensor connected to an Arduino to detect obstacles. It describes the wiring setup, Arduino code for reading the sensor, and printing the status to the serial monitor. The code checks for object presence and provides output based on the sensor's state, indicating whether an obstacle is detected or the path is clear.

Uploaded by

wasiqmath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Arduino IR Sensor Guide

The document outlines a project involving an IR sensor connected to an Arduino to detect obstacles. It describes the wiring setup, Arduino code for reading the sensor, and printing the status to the serial monitor. The code checks for object presence and provides output based on the sensor's state, indicating whether an obstacle is detected or the path is clear.

Uploaded by

wasiqmath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

What We’re Doing

We'll connect an IR sensor to detect if an object is in front of it. Based on the sensor
output, the Arduino will:

• Use if to check the object presence


• Use digitalRead() to read sensor
• Print status using Serial.println()

modules output:
IR Sensor Pin Connect To
• LOW = Obstacle detected VCC 5V
• HIGH = No obstacle GND GND
OUT D8

Arduino Code
void setup() {
pinMode(8, INPUT); // IR sensor output connected to
pin 8
Serial.begin(9600); // Start serial monitor
}

void loop() {
int irState = digitalRead(8); // Read sensor

if (irState == LOW) {
Serial.println("Obstacle Detected!");
} else {
Serial.println("Path Clear.");
}

delay(500); // Half second delay


}

Serial Monitor Output Example

If something is in front of the sensor:

Obstacle Detected!
Obstacle Detected!

If nothing is detected:

Path Clear.
Path Clear.

You might also like