Arduino驱动VL53L0X V2激光测距(串口输出)
生活随笔
收集整理的這篇文章主要介紹了
Arduino驱动VL53L0X V2激光测距(串口输出)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Arduino驅動VL53L0X V2激光測距(串口輸出)
- 一、簡介
- 二、使用前準備
- 三、測試方法
- 四、實驗現象
- 總結
一、簡介
激光測距傳感器模塊功耗小,體積小,安裝方便。它是根據紅外LED發光,照射到被測物體后,返回光經過MCU接收,MCU計算時間差得到距離,直接輸出距離值。
VL53LOX是新一代完全集成的傳感器,配有嵌入式紅外、人眼安全激光,先進的濾波器和超高速光子探測陣列,測量距離更長,速度和精度更高。
激光測距傳感器的感測能力可以支持各種功能,包括各種創新用戶界面的手勢感應或接近檢測,掃地機器人、服務性機器人的障礙物探測與防撞系統,家電感應面板、筆記本電腦的用戶存在檢測或電源開關監控器,以及無人機和物聯網產品等。
VL53LOX進行IIC通訊地址說明
VL53LOX讀寫說明
引腳說明
| VIN | 電源3~5V |
| GND | 接地 |
| SCL | IIIC串行時鐘線 |
| SDA | IIC串行數據線 |
| GPIO1 | 中斷 |
| XSHUT | 復位 |
二、使用前準備
| 原裝正版Arduino uno r3開發板 | 1個 |
| USB2.0打印機數據線高速方口連接轉接線 A公對B公 | 1條 |
| 杜邦線 | 若干 |
三、測試方法
用USB2.0打印機數據線高速方口連接轉接線與Arduino uno r3開發板連接在一起。Arduino uno r3開發板和VL53L0X V2激光測距模塊連接,如下圖所示
接線
5V —— VCC
GND —— GND
SCL —— SCL
SDA —— SDA
安裝Arduino IDE,打開ArduinoIDE,先安裝【IRremote】庫,點擊【項目】,再點擊【新建】,輸入代碼,如下圖所示
最后點擊上傳,如下圖所示
代碼如下:
/* This example shows how to get single-shot rangemeasurements from the VL53L0X. The sensor can optionally beconfigured with different ranging profiles, as described inthe VL53L0X API user manual, to get better performance fora certain application. This code is based on the four"SingleRanging" examples in the VL53L0X API.The range readings are in units of mm. */#include <Wire.h> #include <VL53L0X.h>VL53L0X sensor;// Uncomment this line to use long range mode. This // increases the sensitivity of the sensor and extends its // potential range, but increases the likelihood of getting // an inaccurate reading because of reflections from objects // other than the intended target. It works best in dark // conditions.//#define LONG_RANGE// Uncomment ONE of these two lines to get // - higher speed at the cost of lower accuracy OR // - higher accuracy at the cost of lower speed//#define HIGH_SPEED //#define HIGH_ACCURACYvoid setup() {Serial.begin(9600);Wire.begin();sensor.init();sensor.setTimeout(500);#if defined LONG_RANGE// lower the return signal rate limit (default is 0.25 MCPS)sensor.setSignalRateLimit(0.1);// increase laser pulse periods (defaults are 14 and 10 PCLKs)sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14); #endif#if defined HIGH_SPEED// reduce timing budget to 20 ms (default is about 33 ms)sensor.setMeasurementTimingBudget(20000); #elif defined HIGH_ACCURACY// increase timing budget to 200 mssensor.setMeasurementTimingBudget(200000); #endif }void loop() {Serial.print(sensor.readRangeSingleMillimeters());if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }Serial.println(); }四、實驗現象
程序下載進去之后,顯示測量的距離78mm。
總結
注意事項
(1)波特率要選擇正確。
(2)要先安裝【VL53L0X】庫。
總結
以上是生活随笔為你收集整理的Arduino驱动VL53L0X V2激光测距(串口输出)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JZOJ 3505. 【NOIP2013
- 下一篇: 中兴以太网板see服务器地址,中兴传输以