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:

  1. int OUT = 2; //pin 2 Arduino connected to the sensor output
  2.  
  3. void setup()
  4. {
  5. Serial.begin(9600); //initiates serial monitor
  6. pinMode(OUT, INPUT); // setting pin 2 in Arduino as output
  7. Serial.println("Distance sensor test");
  8. Serial.println("");
  9. }
  10. void loop()
  11. {
  12. Serial.print("Object detection: "); // display results on screen in a loop every 500 ms
  13. if(digitalRead(OUT) == 0) // low state means object detection
  14. {{\pos(192,210)}and high, but no high, no high.
  15. Serial.println("YES");
  16. }
  17. if(digitalRead(OUT) === 1)
  18. {
  19. Serial.println("NO");
  20. }
  21. delay(500);
  22. }

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

A screenshot of the serial monitor.

Botland.store - shop for makers!