Recall & Review
beginner
What does an IR sensor detect in obstacle detection?
An IR sensor detects infrared light reflected from nearby objects to sense obstacles.
Click to reveal answer
beginner
How do you connect an IR sensor to an Arduino for obstacle detection?
Connect the IR sensor's VCC to 5V, GND to ground, and the output pin to an Arduino digital input pin.
Click to reveal answer
beginner
What Arduino function reads the IR sensor output?
Use digitalRead(pin) to read the sensor's output pin, which tells if an obstacle is detected.
Click to reveal answer
beginner
Why do we use an if statement with the IR sensor reading?
To check if the sensor output indicates an obstacle and then take action like stopping a motor.
Click to reveal answer
beginner
What is a simple Arduino code snippet to detect an obstacle using an IR sensor?
int sensorPin = 7;
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void loop() {
int val = digitalRead(sensorPin);
if (val == LOW) {
Serial.println("Obstacle detected!");
} else {
Serial.println("No obstacle.");
}
delay(500);
}
Click to reveal answer
What does the IR sensor output when it detects an obstacle?
✗ Incorrect
Most IR sensors output a LOW digital signal when an obstacle is detected.
Which Arduino function reads a digital pin connected to an IR sensor?
✗ Incorrect
digitalRead() reads the digital value (HIGH or LOW) from a specified pin.
What is the purpose of the delay() function in the IR sensor code?
✗ Incorrect
delay() pauses the program to avoid reading the sensor too fast and to stabilize output.
Which pin mode should be set for the IR sensor output pin on Arduino?
✗ Incorrect
The sensor output pin should be set as INPUT to read its signal.
What happens if you connect the IR sensor output to an analog pin and use digitalRead()?
✗ Incorrect
digitalRead() on an analog pin may not give reliable results; use analogRead() for analog signals.
Explain how an IR sensor detects obstacles and how you use it with Arduino.
Think about how light bounces back and how Arduino reads that signal.
You got /5 concepts.
Describe a simple Arduino program structure to detect obstacles using an IR sensor.
Focus on the main parts of an Arduino sketch for sensor reading.
You got /5 concepts.
