[英]Arduino Ultrasonic Distance Sensor with Passive Buzzer to achieve different tones
[英]flowmeter using two ultrasonic with arduino
我正在做一个由两个超声波、LCD 和 Arduino 组成的项目。
超声波也用于流量测量。 其背后的概念是通过第一个超声波向第二个发送波,计算时间1。 接下来,从第二个发送波,第一个接收波并计算时间2。
如果没有流量,time1 必须等于 time2。 但我不确定我的 arduino 代码是否正确,因为它没有向我显示真实的结果。
这是概念http://www.universalmetering.co.uk/images/mobile/ultrasonic-diagram.gif
你能检查一下吗,如果你有代码给它..
谢谢..
LiquidCrystal LCD(11,10,9,2,3,4,5);
//Create Liquid Crystal Object called LCD
#define trigPin1 12 #define echoPin1 13
#define trigPin2 8
#define echoPin2 7
//Simple program just for testing the HC-SR04 Ultrasonic Sensor with LCD dispaly //URL:
void setup()
{
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
LCD.begin(16,2);
//Tell Arduino to start your 16 column 2 row LCD
LCD.setCursor(0,0); //Set LCD cursor to upper left corner, column 0, row 0
LCD.print("Difference in time:"); //Print Message on First Row
}
void loop()
{
long duration1, duration2, diff;
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
duration1 = pulseIn(echoPin2, HIGH);
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
duration2 = pulseIn(echoPin1, HIGH);
diff = (duration2) - (duration1);
LCD.setCursor(0,1); //Set cursor to first column of second row
LCD.print(" "); //Print blanks to clear the row
LCD.setCursor(0,1); //Set Cursor again to first column of second row
LCD.print(diff); //Print measured distance
LCD.print(" sec"); //Print your units.
delay(250); //pause to let things settle
}
SR-04 在触发时提供回声响应。 这发生在同一个模块中。 即触发一个模块trigPin1
和阅读等模块echoPin2
带来近随机的,不相关的结果。
阅读echoPin1
触发后trigPin1
。
SR-04 可以记录从空气中返回 20 厘米或更远距离的声音。 大约需要最短的时间。 0.6 毫秒(588 纳秒)。 对于 SR-04 来说,低于这个值就是“无”。
声音在水中的传播速度大约是在空气中的 5 倍。 此外,SR-04 中接收器和发射器之间的距离非常小。 同样,管道宽度很窄,不是为 SR-04 设计的。
因此,即使将发射器和接收器放置在 10 厘米之外,使用 1 英寸宽的管道,在水中的预期返回时间约为 0.1 毫秒(100 纳秒)。 这是 SR-04 注册功能的背后。
但是,您可能想要构建自己的 TOF 计,使用TDC-GP22模块加上分离的超声波接收器和发射器以及适当的电源管理。 这是一个非常复杂(而且不像 SR-04 那样便宜)的项目,它受益于非侵入性液体流量测量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.