02. I2C Address
2022. 8. 28. 01:09
Lidar ์ผ์๋ Address ๊ฐ(0x62)์ default๋ก ๊ฐ์ง๊ณ ์์ผ๋ฏ๋ก ์ด๋ฅผ ๋ณ๊ฒฝํด์ฃผ์ด์ผ ์ฌ๋ฌ๊ฐ๋ฅผ ์ฌ์ฉํ์ ๋ ๊ตฌ๋ณ ๊ฐ๋ฅ
๐ LIDAR_Lite_v3 datasheet
1. Read the two byte serial number from 0x96 (High: 0x16 Low: 0x17)
2. Write the serial number high byte to 0x18
3. Write the serial number low byte to 0x19
4. Write the desired new I2C address to 0x1a
5. Write 0x08 to 0x1e to disable the default address
โ๏ธBegin ์์
LIDARLite.cpp (๐ line 51)
void LIDARLite::begin(int configuration, bool fasti2c, char lidarliteAddress)
LIDARLite.ino
lidarLite.begin(0, true, 0x62);
โ๏ธConfigure ์์
LIDARLite.cpp (๐ line 86)
void LIDARLite::configure(int configuration, char lidarliteAddress)
LIDARLite.ino
lidarLite.configure(0, 0x62);
โ๏ธsetI2Caddr ์ถ๊ฐ
LIDARLite.cpp (๐ line 141)
void LIDARLite::setI2Caddr(char newAddress, char disableDefault, char lidarliteAddress)
LIDARLite.ino โจ 0x64๋ก ๋ณ๊ฒฝํ๊ณ ์ ํจ
lidarLite.setI2Caddr(0x64, 0x08, 0x62);
โ๏ธdistance ๋ณ๊ฒฝ
LIDARLite.cpp (๐ line 207)
int LIDARLite::distance(bool biasCorrection, char lidarliteAddress)
LIDARLite.ino โจ 0x64๋ก ๋ณ๊ฒฝํ๊ณ ์ ํจ
dist = lidarLite.distance(true, 0x64);
โ๏ธI2C Address ๋ณ๊ฒฝํ๋ Arduino Code
#include <Wire.h>
#include <LIDARLite.h>
LIDARLite lidarLite;
int cal_cnt = 0;
void setup()
{
Serial.begin(9600);
lidarLite.begin(0, true, 0x62);
lidarLite.configure(0, 0x62);
lidarLite.setI2Caddr(0x64, 0x08, 0x62);
}
void loop()
{
int dist;
if ( cal_cnt == 0 ) {
dist = lidarLite.distance(true, 0x64);
}
else {
dist = lidarLite.distance(false, 0x64);
}
cal_cnt++;
cal_cnt = cal_cnt % 100;
Serial.print(dist);
Serial.println(" cm");
delay(10);
}
โ๏ธI2C Address ๋ณ๊ฒฝ ํ์ธ Arduino Code
#include <Wire.h>
#include <LIDARLite.h>
LIDARLite lidarLite, lidarLite2;
int cal_cnt = 0;
unsigned char read_value[2];
void setup()
{
Serial.begin(9600);
lidarLite.begin(0, true, 0x62);
lidarLite.configure(0, 0x62);
lidarLite.setI2Caddr(0x64, 0x08, 0x62);
lidarLite.read((0x1a | 0x80), 1, read_value, false, 0x64);
}
void loop()
{
int dist;
if ( cal_cnt == 0 ) {
dist = lidarLite.distance(true, 0x64);
}
else {
dist = lidarLite.distance(false, 0x64);
}
cal_cnt++;
cal_cnt = cal_cnt % 100;
Serial.print(dist);
Serial.println(" cm");
Serial.print(read_value[0]);
delay(10);
}
โฒread ๊ฐ์ ๋ฃ์ด์ฃผ์ด Serial Monitor์ 0x64๊ฐ์ธ 100์ ์ถ๋ ฅ
โ๏ธ๋จ์
์ ์์ ๊ป๋ค ์ผ๋ฉด reset ๋จ
โจ ๋งค๋ฒ ์ฝ๋๋ฅผ ์
๋ก๋ ์์ผ์ฃผ์ด์ผ ํจ
'๐ญ Project > ๐ Lidar-Lite V3' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
04. Power Enable (0) | 2022.08.28 |
---|---|
03. Time Stamp (0) | 2022.08.28 |
01. Survey (0) | 2022.08.28 |