Infrared Sensor¶
Working principle: Reflection of light
Uses¶
- Obstacle detection
- Differentiate between colors
Components¶
- Transmitter: IR LED
- Receiver: Photodiode (Reverse LED)
- Comparator IC for voltage comparison
- Potentiometer to set sensitivity of sensor, by controlling voltage threshold for comparator
- \(V_s \ne \{0, V_{cc} \}\)
Working steps¶
- Transmitter emits IR rays
- Light gets reflected by obstacle
- Receiver gets the reflected light
- Received light converted into voltage
Limitations¶
- Cannot obtain position of obstacle; only for Object-Detection (binary)
- Obstacle detection only works for light-colored obstacle
- dark colored objects will absorb light
Circuit Diagram¶
Code¶
int objected_detected
void setup(){
pinMode(D1, INPUT); // sensor
pinMode(D2, OUTPUT); // output device (LED)
Serial.begin(9600);
}
void loop(){
objected_detected = digitalRead(D1);
Serial.println(objected_detected);
if (objected_detected == 1) {
digitalWrite(D2, HIGH);
} else {
digitalWrite(D2, LOW);
}
delay(500);
}