Categories

Distance measurement using Arduino and sensor E18-D80NK

Distance measurement using Arduino and a sensor E18-D80NK

The sensor allows you to measure distances. But it works zero-jedynkowo. Or the object was detected or not. Sensitivity adjustment and is carried out through the handle in the housing of the module. This sensor may not give the measured distance (as the HC-SR04 or US-015).

 

We will need the following items:

 

Connect the sensor with Arduino:

The sensor using the Arduino you should connect the layout as follows:

 

Module E18-D80NKPin Arduino
The wire is red or brown5 V
Wire - green or blueGND
Wire yellow or black2

 

 

The connection scheme of sensor with the Arduino Uno.

Program for Arduino

In the example, we used the following code:

 

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

void setup() 
{ 
 Serial.begin(9600); //inicjalizaja monitor serial port 
 pinMode(OUT, INPUT); //setting Arduino pin 2 as output 
 Serial.println("Test of spacing"); 
 Serial.println(""); 
} 

void loop() 
{ 

 Serial.print("object: "); //display results on the screen in a loop for 500 MS 
 if(digitalRead(OUT) == 0) //low state indicates detection of the object 
 { //status is high, and the lack of 
 Serial.println("YES"); 
 } 
 if(digitalRead(OUT) == 1) 
 { 
 Serial.println("NOT"); 
 } 
 delay(500); 
} 

 

The result of the program we can see on the serial monitor:

 

A screenshot of the serial monitor.