forked from henjin0/Lidar_LD06_for_Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLD06_sample.ino
More file actions
32 lines (24 loc) · 740 Bytes
/
Copy pathLD06_sample.ino
File metadata and controls
32 lines (24 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <M5Atom.h>
#include "LD06forArduino.h"
#include <algorithm>
LD06forArduino ld06;
void setup() {
M5.begin(true, false, true);
delay(10);
Serial.begin(115200);
ld06.Init(19);
}
void loop() {
// put your main code here, to run repeatedly:
M5.update();
//Serial.println("data start");
ld06.read_lidar_data();
Serial.printf("start_bytet:%d, data_length:%d, Speed:%f, FSA:%f, LSA:%f, time_stamp:%d, CS:%d",
ld06.start_byte, ld06.data_length, ld06.Speed, ld06.FSA, ld06.LSA, ld06.time_stamp, ld06.CS);
Serial.println();
for (int i = 0; i < ld06.data_length; i++) {
if (ld06.angles[i] > -3 && ld06.angles[i] < 3 && ld06.distances[i] < 300)
Serial.print("Hit!");
}
//delay(10);
}