Skip to content
Snippets Groups Projects
Commit 0757569d authored by Orhan-Timo Altan's avatar Orhan-Timo Altan
Browse files

Mit 5 ToFs getestet

parent a9e4d8e1
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ Diese Bibliothek verwendet die Adafruit_VL53L0X Bibliothek um einen Array mit me
Getestet mit:
- Arduino Mega Pro + 3x VL53L0X<br />
- Arduino Mega Pro + 5x VL53L0X<br />
<br />
## **Vorrausetzung**
......
......@@ -11,6 +11,19 @@ void setup() {
void loop() {
get_tof_distance(0);
int test = get_tof_distance(0);
int test2 = get_tof_distance(1);
int test3 = get_tof_distance(2);
int test4 = get_tof_distance(3);
int test5 = get_tof_distance(4);
Serial.print(test);
Serial.print(" ");
Serial.print(test2);
Serial.print(" ");
Serial.print(test3);
Serial.print(" ");
Serial.print(test4);
Serial.print(" ");
Serial.println(test5);
}
\ No newline at end of file
......@@ -14,8 +14,9 @@
const int ToFs = 5; // Anzahl der zu Verwendenden Time of Flight Sensoren
const int ToF_XShuts[ToFs] = {NULL, 9, 11, 31, A10}; // XShut Pins der einzelnen Time of Flight Sensoren
const int ToF_Addresses[ToFs] = {0x30, 0x31, 0x32, 0x33, 0x34}; // Adresse der einzelnen Time of Flight Sensoren
int tof_dist;
#define DEBUG
// #define DEBUG
#ifdef DEBUG
#define _println_(x) Serial.println(x)
#define _print_(x) Serial.print(x)
......@@ -81,17 +82,20 @@ void tof_init() {
}
}
void get_tof_distance(int i){
int get_tof_distance(int i){
VL53L0X_RangingMeasurementData_t measure;
sensors[i].psensor->rangingTest(&measure, false); // 'true' um debug Informationen auszugeben
if (measure.RangeStatus != 4) { // phase failures have incorrect data
tof_dist = measure.RangeMilliMeter/10;
_print_(i);
_print_(" Sensor Entfernung (cm): ");
_println_(measure.RangeMilliMeter/10);
_println_(tof_dist);
} else {
_println_(" Ausserhalb des Messbereichs ");
tof_dist = 0;
}
return tof_dist;
}
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment