04. Power Enable
2022. 8. 28. 01:12
โ๏ธPower Enable?
• ์ ์์ ์กฐ์ ํด์ ์ค ์ ์๋ ๊ฒ
• Lidar-Lite V3: ์ฃผํฉ์ ์
• Internal Pullup์ด๋ฏ๋ก High์ผ ๋ ์ ์ ๊ณต๊ธ
โ๏ธArduino Code
#include <WiFi.h>
#include "time.h"
#include <Wire.h>
#include <LIDARLite.h>
LIDARLite lidarLite, lidarLite2;
int cal_cnt = 0;
const char* ssid = "pia071";
const char* password = "92423071";
const char* ntpServer = "pool.ntp.org";
unsigned long epochTime;
unsigned long getTime() {
time_t now;
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
return(0);
}
time(&now);
return now;
}
void initWiFi() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi ..");
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(1000);
}
Serial.println(WiFi.localIP());
}
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
pinMode(14, OUTPUT);
digitalWrite(14, LOW);
Serial.begin(115200);
initWiFi();
configTime(0, 0, ntpServer);
digitalWrite(13, HIGH);
delay(2000);
lidarLite.begin(0, true, 0x62);
lidarLite.configure(0, 0x62);
lidarLite.setI2Caddr(0x64, 0x08, 0x62);
Serial.println("initial_1");
digitalWrite(14, HIGH);
delay(2000);
lidarLite2.begin(0, true, 0x62);
lidarLite2.configure(0, 0x62);
Serial.println("initial_2");
}
void loop() {
epochTime = getTime();
Serial.print("Unix Time: ");
Serial.println(epochTime);
int dist;
int dist2;
if ( cal_cnt == 0 ) {
dist = lidarLite.distance(true, 0x64);
dist2 = lidarLite2.distance(true, 0x62);
} else {
dist = lidarLite.distance(false, 0x64);
dist2 = lidarLite2.distance(false, 0x62);
}
cal_cnt++;
cal_cnt = cal_cnt % 100;
Serial.print("dist1:");
Serial.print(dist);
Serial.println(" cm");
Serial.print("dist2:");
Serial.print(dist2);
Serial.println(" cm");
delay(1000);
}
• GPIO13์ Lidar1 ์ฐ๊ฒฐ
• GPIO14์ Lidar2 ์ฐ๊ฒฐ
• Initial ์ ์ HIGH๋ก ๋ฐ๊พธ์ด์ฃผ๊ธฐ
• ์ ์ ๊ณต๊ธ ํ ์๊ฐ์ด ์กฐ๊ธ ํ์ํ๋ฏ๋ก delay(2000);
'๐ญ Project > ๐ Lidar-Lite V3' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
03. Time Stamp (0) | 2022.08.28 |
---|---|
02. I2C Address (0) | 2022.08.28 |
01. Survey (0) | 2022.08.28 |