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.
Revision 0:e26f2e97182d, committed 2022-05-08
- Comitter:
- sas638
- Date:
- Sun May 08 20:14:38 2022 +0000
- Commit message:
- ok;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Sun May 08 20:14:38 2022 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TB6612.lib Sun May 08 20:14:38 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/sas638/code/TB6612/#f51c00c6d476
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VL53L0X.lib Sun May 08 20:14:38 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/joelvonrotz/code/VL53L0X/#ccc67c76fecb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun May 08 20:14:38 2022 +0000
@@ -0,0 +1,72 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+#include "tb6612.h"
+#include "VL53L0X.h"
+
+I2C i2c(D14,D15);
+VL53L0X vl_sensors[3] = {(&i2c),(&i2c),(&i2c)}
+BusOut vl_shutdown(D0,D1,D3);
+Serial usb(USBTX. USBRX, 115200);
+TB6612 motorL(D2,D4,D5);
+TB6612 motorR(D9,D10,D11);
+
+float DR; //distance measured if need to turn 45º right - manual measured value
+float DL; //distance measured if need to turn 45º left - manual measured value
+float D; // distance measured to go straight - given value
+float TM; //Time needed to turn 45º in either direction
+float DI; // distance measured
+float R; //Ratio between D1 and D
+float T; //Calculated turn time for current offset
+float Dlefts; //left sensor reading
+float Drights; //right sensor reading
+float Dfronts; // front sensor reading
+
+int main()
+{
+ usb.printf("Multiple VL53L0X\n\r");
+
+ uint8_t expander_shutdown_mask = 1;
+ for(uint8_t i = 0; i < 3; i++) {
+ vl_shutdown = expander_shutdown_mask;
+ expander_shutdown_mask = (expander_shutdown_mask << 1) + 1;
+ vl_sensors[i].init();
+ vl_sensors[i].setDeviceAddress(0x40 + i);
+ vl_sensors[i].setModeContinuous();
+ vl_sensors[i].startContinuous();
+ }
+ uint16_t results[3];
+
+ while(1) {
+ for(uint8_t i = 0; i < 3; i++) {
+ results[i] = vl_sensors[i].getRangeMillimeters();
+ }
+ Dfronts = results[0];
+ Dlefts = results[1];
+ Drigts = results [2];
+
+ DI = Dfronts;
+
+ if(DI>D) {
+ R = DR/DI;
+ T = TM/R;
+ motorR.setSpeed(-1);
+ motorL.setSpeed(1);
+ usb.printf("right turn\n\r");
+ wait(T);
+ }
+ if (DI<D) {
+ R = DL/DI;
+ T = TM/R;
+ motorR.setSpeed(1);
+ motorL.setSpeed(-1);
+ usb.printf("left turn\n\r");
+ wait(T);
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Sun May 08 20:14:38 2022 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9
Binary file resources/official_armmbed_example_badge.png has changed