In this project, we are using E18-D80NK IR Proximity Sensor which we will interface with Arduino.
The E18-D80NK is an IR Proximity Sensor with an obstacle detection range approx 3 cm to 80 cm. The utilization of modulated IR signal prevents the sensor from the interferences caused by the normal light of the sunlight.
E18-D80 IR Sensor is generally utilized in robots to avoid obstacles. The detection range can be adjusted as per the application with the help of the multi-turn screw that is placed at the back of the sensor.
For the connection of Interfacing of E18-D80NK IR Sensor with Arduino, attach the Brown wire of sensor with Arduino 5V pin, attach the Blue wire of sensor with Arduino’s Ground and attach Black pin of a sensor with a digital pin 7 of Arduino Nano.
const int e18_sensor = 7;
const int led = 2;
void setup() {
Serial.begin(9600);
pinMode (e18_sensor, INPUT);
pinMode (led, INPUT);
}
void loop() {
int state = digitalRead(e18_sensor);
Serial.println(state);
if(state==LOW){
Serial.println("Object Detected");
digitalWrite(led, HIGH);
}
else {
Serial.println("All Clear");
digitalWrite(led, LOW);
}
delay(1000);
}