[Diao Ye learns programming] Arduino hands-on (139)---E18-D80 obstacle avoidance sensor module 3

insert image description here

The reference to 37 sensors and actuators has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensor and actuator modules on hand, according to the concept of practice to get true knowledge (must be done), for the purpose of learning and communication, I am going to try a series of experiments one by one, regardless of success (the program goes through) or not, They will be recorded - small progress or unsolvable problems, hoping to inspire others.

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 139: E18-D80NK infrared obstacle avoidance sensor module proximity switch smart car 3-80cm

insert image description here

The experimental environment of the E18 - D80NK infrared obstacle avoidance sensor module
1. The hardware list required for the experiment of the infrared obstacle avoidance sensor
module Diode (green, blue) X2 High level trigger single 5V relay module X1 E18-D80NK infrared obstacle avoidance sensor module X1 Proto Shield prototype expansion board (with mini breadboard) X1





insert image description here

2. Software platforms required for sensor module experiments
Code programming Arduino IDE (version 1.8.19),
simulation programming Linkboy (version V4.6.3),
graphics programming Mind+ (version V1.7.0 RC2.0)
and learning by playing (online platform https ://ide.codepku.com/?type=Arduino)

3. Schematic diagram of the experimental wiring of the infrared obstacle avoidance sensor module Pin
arrangement:
Brown: VCC, 5VDC positive power supply
Blue: GND, negative power supply 0VDC
Black: The signal pin of the NPN transistor structure has pulled the internal 10k resistor to VCC.

insert image description here
4. Instructions for the use of the module
Because the sensor has pulled 10k to VCC, the high-level voltage of the sensor signal pin (Vout) is also the VCC voltage. There are two situations: 1.
If the circuit needs to use a voltage equal to the VCC voltage of the sensor Signal level for communication (for example, the power supply of the sensor and Arduino is the same, VCC=5VDC, the communication voltage of Arduino is also 5VDC and the Vout of the sensor. If the variable is also 5VDC), there is no need to connect the resistor Rx, directly connect the signal pin of the sensor to the signal pin of the Arduino.
2. If the circuit needs to communicate with a signal level different from the VCC voltage of the sensor (for example, the sensor level VCC=10VDC, the communication voltage of Arduino=5VDC), then an additional resistor Rx as shown below needs to be connected to Vout=5VDC The value of Rx does not burn the Arduino circuit, the value of Rx is calculated according to the voltage division formula: Rx= (Vout R1) / (VCC-Vout) = (5 10) / (10-5) ) = 10k.

insert image description here

Several experiments of the E18-D80NK infrared obstacle avoidance sensor module
Procedure 1: Display the output waveform of the E18-D80NK module through the serial port
(1) Arduino reference open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  程序一:通过串口显示E18-D80NK模块的输出波形
  实验接线:红外避障连接Uno的A0
*/

void setup() {
    
    
  Serial.begin(9600);  // 设置串口波特率为9600
  pinMode(A0, INPUT);  // 红外避障连接引脚A0,并设置为输入模式
}

void loop() {
    
    
  //将读取的数值输出到串口监视器
  Serial.println(analogRead(A0));
  delay(500); // 延时500毫秒
}

(2) The return status of the experimental serial port

insert image description here
(3) Open Arduino IDE - Tools - Serial Port Plotter to view the experimental waveform

insert image description here
(4) The return status of the experimental serial port plotter

insert image description here

Procedure 2: Use E18-D80NK to detect obstacles
(1) Schematic diagram of experimental wiring

insert image description here
(2) Arduino reference open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  程序二:使用E18-D80NK检测障碍物体
*/

#define D80NK 2 // 模块接D2
#define LED 13 // LED接D13

void setup() {
    
    
  Serial.begin(9600);//设置串口监视器显示信息
  pinMode(D80NK, INPUT_PULLUP);//定义引脚为输入传感器
  pinMode(LED, OUTPUT);//定义LED为输出
}

void loop() {
    
    
  int L = digitalRead(D80NK); //读取传感器
  Serial.println(L);
  
  if (L == HIGH) {
    
    
    Serial.println("检测到障碍物");
    digitalWrite(LED, HIGH); //发送信号,点亮LED

  } else {
    
    

    Serial.println("=== 全部清除");
    digitalWrite(LED, LOW); //关闭LED
  }
  delay(1000);
}

(3) The return status of the experimental serial port

insert image description here
Program 3: Infrared obstacle avoidance sensor controls LED
(1) Experimental open source simulation programming (Linkboy V4.63)

insert image description here
(2) Experimental scene diagram

insert image description here

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/132353783