A gesture project based on X_NUCLRO_53L1A1
Dependencies: Test_SSD1306 mbed X_NUCLEO_53L1A1
Diff: main.cpp
- Revision:
- 0:5ea7efe9f6c9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Sep 02 16:02:17 2022 +0000
@@ -0,0 +1,42 @@
+#include <stdint.h>
+#include <stdio.h>
+#include "mbed.h"
+#include "XNucleo53L1A1.h"
+#include "VL53L1X_I2C.h"
+
+uint16_t distance_centre = 0;
+uint16_t distance_left = 0;
+int16_t distance_right = 0;
+uint8_t state =0;
+uint8_t command = 0;
+int wait_fun();
+
+void speed(void)
+{
+ if (command == 1 ) {
+ printf("go forward, speed = %d\r\n",distance_centre - 80);
+ } else if (command == 2) {
+ printf("go back, speed = %d\r\n",50 - distance_centre);
+ } else if (command == 3) {
+ printf("Waiting, speed = 0\r\n");
+ } else if (command == 7) {
+ printf("turn right\r\n");
+ } else if (command == 8) {
+ printf("turn left\r\n");
+ } else if (command ==5) {
+ printf("left forward, speed = %d\r\n",distance_centre - 80);
+ } else if (command ==55) {
+ printf("left backward, speed = %d\r\n",50 - distance_centre);
+ } else if (command == 6) {
+ printf ("right forward, speed = %d\r\n",distance_centre - 80);
+ } else if (command == 66) {
+ printf ("right backward, speed = %d\r\n",50 - distance_centre);
+ } else if (command == 4) {
+ printf("Stop\r\n");
+ }
+}
+
+void main()
+{
+ speed();
+}
\ No newline at end of file