VL53L0X激光測距,oled顯示,單位mm,親測最小距離50mm,下載后可直接使用,看現象
單片機源程序如下:
- #include "VL53L0X.h"
- void vl53l0x_send(uchar reg,uchar dat)
- {
- I2C_Start();
- I2C_SendByte(address);
- I2C_SendByte(reg);
- I2C_SendByte(dat);
- I2C_Stop();
- }
- uchar vl53l0x_read(uchar reg)
- {
- unsigned char num;
- I2C_Start();
- I2C_SendByte(address); //發送寫器件地址
- I2C_SendByte(reg); //發送要讀取的地址
- I2C_Stop();
- I2C_Start();
- I2C_SendByte(address+1); //發送讀器件地址
- num=I2C_ReadByte(); //讀取數據
- I2C_Stop();
- return num;
- }
- short makeuint16(int lsb, int msb)
- {
- return ((msb & 0xFF) << 8) | (lsb & 0xFF);
- }
- //unsigned short VL53L0X_decode_vcsel_period(short vcsel_period_reg)
- //{
- // // Converts the encoded VCSEL period register value into the real
- // // period in PLL clocks
- // unsigned short vcsel_period_pclks = (vcsel_period_reg + 1) << 1;
- // return vcsel_period_pclks;
- //}
復制代碼
所有資料51hei提供下載:
VL530X0L激光測距.zip
(108.63 KB, 下載次數: 395)
2019-8-5 08:58 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|