Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 1:e54ded4af43a
- Child:
- 2:f570ff03fb81
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Aug 08 21:44:33 2018 +0000
@@ -0,0 +1,78 @@
+#include "mbed.h"
+#include "VL53L1X.h"
+void resetPin(int pin);
+
+Serial pc(USBTX,USBRX);
+
+bool s1_init = false;
+bool s2_init = false;
+bool s3_init = false;
+bool s4_init = false;
+
+VL53L1X sensor1(D14, D15, D0);
+VL53L1X sensor2(D14, D15, D1);
+VL53L1X sensor3(D14, D15, D2);
+VL53L1X sensor4(D14, D15, D3);
+
+int count = 0;
+int main()
+{
+ sensor1.turnOff();
+ sensor2.turnOff();
+ sensor3.turnOff();
+ sensor4.turnOff();
+ if (sensor2.initReading(0x25, 25000))
+ {
+ s2_init = true;
+ }
+ if (sensor1.initReading(0x27, 25000))
+ {
+ s1_init = true;
+ }
+ if (sensor3.initReading(0x35, 25000))
+ {
+ s3_init = true;
+ }
+ if (sensor4.initReading(0x37, 50000))
+ {
+ s4_init = true;
+ }
+ while(1)
+ {
+
+ sensor1.startContinuous(50);
+ sensor2.startContinuous(50);
+ sensor3.startContinuous(50);
+ sensor4.startContinuous(50);
+
+ if (s1_init)
+ pc.printf("%d", sensor1.read());
+ else
+ pc.printf("-1");
+
+ pc.printf(",");
+
+ if (s2_init)
+ pc.printf("%d", sensor2.read());
+ else pc.printf("-1");
+
+ pc.printf(",");
+
+ if (s3_init)
+ pc.printf("%d", sensor3.read());
+ else pc.printf("-1");
+
+ pc.printf(",");
+
+ if (s4_init)
+ pc.printf("%d", sensor4.read());
+ else pc.printf("-1");
+
+ pc.printf("\r\n");
+ sensor1.stopContinuous();
+ sensor2.stopContinuous();
+ sensor3.stopContinuous();
+ sensor4.stopContinuous();
+ wait(.02);
+ }
+}