Microduino Ultrasonic ranging-OLED display distance

来自Microduino Wikipedia
Pkj讨论 | 贡献2014年4月23日 (三) 12:59的版本 (Created page with "{{Language | Microduino 超声波测距-OLED显示}} {| style="width: 800px;" |- | ==Objective== This tutorial will teach you using the ultrasonic sensor to measure distance a...")
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索
Language English

Objective

This tutorial will teach you using the ultrasonic sensor to measure distance and displays on Microduino OLED.

Equipment


Schematic


Program

Refer to UltrasonicOLED

The following is the distance measurement algorithm:

digitalWrite(TrigPin, LOW); //Send a pulse to TrigPin

delayMicroseconds(2);

digitalWrite(TrigPin, HIGH);

delayMicroseconds(10);

digitalWrite(TrigPin, LOW);

cm = pulseIn(EchoPin, HIGH) / 58.0; //Convert the timer to distance (cm) (The propagation of sound speed is 340 m/s)

cm = (int(cm * 100.0)) / 100.0; //Keep two decimal places


Debug

Step 1:Stack all the required Microduino module, as follows:

Step 2:Compile the program and download it.

Step 3:Run program, put a object in front of sensor, then move it, observe the OLED's value.


Result

OLED will display the distance between sensor and object.

Video

http://v.youku.com/v_show/id_XNzAxMDc5Mjcy.html