|
US-015使用說(shuō)明書及例程-V2.0+SA-260
US-015是US-020模塊的升級(jí)版本,和US-020兼容,以前US-020的測(cè)試程序US-015也適用。
US-015超聲波測(cè)距模塊例程與US-020的測(cè)試?yán)滔嗤?br />
文件夾“US_015_GPIO_HighPrecision_ino”是用Arduino進(jìn)行控制的高精度測(cè)距版本。
0.png (48.13 KB, 下載次數(shù): 89)
下載附件
2018-5-17 05:12 上傳
0.jpg (38.88 KB, 下載次數(shù): 87)
下載附件
2018-5-17 05:12 上傳
0.jpg (32.53 KB, 下載次數(shù): 84)
下載附件
2018-5-17 05:12 上傳
文件夾中的pde文件為Arduino的工程文件,可通過(guò)記事本打開(kāi)和編輯。
US-015_GPIO_Arduino源程序如下:
- unsigned int EchoPin = 2; // connect Pin 2(Arduino digital io) to Echo at US-015
- unsigned int TrigPin = 3; // connect Pin 3(Arduino digital io) to Trig at US-015
- unsigned long Time_Echo_us = 0;
- unsigned long Len_mm = 0;
- void setup()
- { //Initialize
- Serial.begin(9600); //Serial: output result to Serial monitor
- pinMode(EchoPin, INPUT); //Set EchoPin as input, to receive measure result from US-015
- pinMode(TrigPin, OUTPUT); //Set TrigPin as output, used to send high pusle to trig measurement (>10us)
- }
- void loop()
- {
- digitalWrite(TrigPin, HIGH); //begin to send a high pulse, then US-015 begin to measure the distance
- delayMicroseconds(20); //set this high pulse width as 20us (>10us)
- digitalWrite(TrigPin, LOW); //end this high pulse
-
- Time_Echo_us = pulseIn(EchoPin, HIGH); //calculate the pulse width at EchoPin,
- if((Time_Echo_us < 60000) && (Time_Echo_us > 1)) //a valid pulse width should be between (1, 60000).
- {
- Len_mm = (Time_Echo_us*34/100)/2; //calculate the distance by pulse width, Len_mm = (Time_Echo_us * 0.34mm/us) / 2 (mm)
- Serial.print("Present Distance is: "); //output result to Serial monitor
- Serial.print(Len_mm, DEC); //output result to Serial monitor
- Serial.println("mm"); //output result to Serial monitor
- }
- delay(1000); //take a measurement every second (1000ms)
- }
復(fù)制代碼
所有資料51hei提供下載:
US-015使用說(shuō)明書及例程-V2.0 SA-260.rar
(2.21 MB, 下載次數(shù): 99)
2018-5-16 13:20 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
|