Distance measurement using Arduino and E18-D80NK sensor

The sensor enables distance measurement. However, it works zero-one. Either an object is detected or not. The sensitivity is adjusted by means of a knob in the module housing. This sensor cannot give the measured distance (such as HC-SR04 or US-015).

You will need the following items:

Connecting the sensor from Arduino:

To operate the sensor with Arduino, connect the circuit as follows:

E18-D80NK module Pin Arduino
Red or brownwire 5 V
Green or bluewire GND
Yellow or blackwire 2

Wiring diagram of the sensor from Arduino Uno.

Program for Arduino

The following code was used in the example:

int OUT = 2; //pin 2 Arduino connected to the sensor output

void setup()
{
  Serial.begin(9600); //initiates serial monitor
  pinMode(OUT, INPUT); // setting pin 2 in Arduino as output
  Serial.println("Distance sensor test");
  Serial.println("");
}
 
void loop()
{
  
  Serial.print("Object detection: "); // display results on screen in a loop every 500 ms
  if(digitalRead(OUT) == 0) // low state means object detection
  {{\pos(192,210)}and high, but no high, no high.
    Serial.println("YES");
  }
  if(digitalRead(OUT) === 1)
  {
    Serial.println("NO");
  }
  delay(500);
}

The result of the program can be observed on a serial monitor:

A screenshot of the serial monitor.

Botland.store - shop for makers!