超声波测距接线图详细_超声波数显仪DIY测距数显

本文详细介绍了如何使用超声波测距接线图进行DIY制作数显测距仪,涵盖了从接线到显示的全过程。
摘要由CSDN通过智能技术生成
今天做一个超声波测距的仪器,有想了解超声波的百度百科哈,说的很详细。LCD1602的应用,结合超声波模块,实现测距数显的小仪器。

a9646148249df2f2cc72c6ec82615540.png

接线图中我没有将电池充电口留出来,有做DIY的朋友可以将充电口留出来,以便长期使用。 02a85da022cb9155be79359ef0ce1112.png 5bf101bd80ff5b8739b3b04de0622b6e.png
#include #include LiquidCrystal_I2C lcd(0x27,16,2);// if your LCD does not display,change it to 0x27 or other addressconst int trigPin = 4;const int echoPin = 3;// defines variableslong duration;int distance;void display1(){    lcd.setCursor(0,0);    lcd.print("Distance:");    lcd.setCursor(13, 1);    lcd.print("cm");   }void setup() {  // put your setup code here, to run once:  lcd.init();                      // initialize the lcd  lcd.backlight();     pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output  pinMode(echoPin, INPUT); // Sets the echoPin as an Input  Serial.begin(9600); // Starts the serial communication  pinMode(5,OUTPUT);     //virtual power pin  digitalWrite(5,HIGH); // virtual power pin  pinMode(2,OUTPUT);     //virtual power pin  digitalWrite(2,LOW);  }void loop() {  // put your main code here, to run repeatedly:  digitalWrite(trigPin, LOW);  delayMicroseconds(2);                                      // Sets the trigPin on HIGH state for 10 micro seconds  digitalWrite(trigPin, HIGH);  delayMicroseconds(10);  digitalWrite(trigPin, LOW);                                       // Reads the echoPin, returns the sound wave travel time in microseconds  duration = pulseIn(echoPin, HIGH);                                       // Calculating the distance  distance= duration*0.034/2;                                     // Prints the distance on the Serial Monitor  Serial.print("Distance: ");  Serial.println(distance);  display1();  lcd.setCursor(8,1);  lcd.print(distance);  delay(1000);  lcd.clear();  }
超声波是声波的一部分,是人耳听不见、频率高于20KHZ的声波,它和声波有共同之处,即都是由物质振动而产生的,并且只能在介质中传播;同时,它也广泛地存在于自然界,许多动物都能发射和接收超声波,其中以蝙蝠最为突出,它能利用微弱的超声回波在黑暗中飞行并捕捉食物。但超声还有它的特殊性质'如具有较高的频率与较短的波长,所以,它也与波长很短的光波有相似之处。 超声波是弹性机械振动波,它与可听声相比还有一些特点:传播的方向较强,可聚集成定向狭小的线束;在传播介质质点振动的加速度非常之大;在液体介质中当超声强度达到一定值后便会发生空化现象。 利用超声的机械作用、空化作用、热效应和化学效应,可进行超声焊接、钻孔、固体的粉碎、乳化 、脱气、除尘、去锅垢、清洗、灭菌、促进化学反应和进行生物学研究等,在工矿业、农业、医疗等各个部门获得了广泛应用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值