dad

Dependencies:   mbed-os FXAS21000 LED_Bar FXOS8700Q

Revision:
1:7a49fd0692fd
Parent:
0:838685d68d89
Child:
2:d08625231a9f
diff -r 838685d68d89 -r 7a49fd0692fd main.cpp
--- a/main.cpp	Fri Jan 15 22:11:19 2021 +0000
+++ b/main.cpp	Mon Mar 07 00:30:36 2022 +0000
@@ -15,6 +15,13 @@
         int16_t raX, raY, raZ, rmX, rmY, rmZ, tmp_int;
         acc.enable();
         mag.enable();
+        DigitalOut Red(LED1);
+        Red=1;
+        DigitalOut Blue(LED3);
+        DigitalOut Green(LED2);
+        Blue=1;
+        Green=1;
+        
         while (true) {
             // counts based results
             acc.getAxis(acc_raw);
@@ -34,10 +41,28 @@
             mag.getX(fmX);
             mag.getY(fmY);
             mag.getZ(fmZ);
-           pc.printf("FXOSQ8700Q ACC: X=%1.4fY=%1.4fZ=%1.4f", acc.getX(faX),acc.getY(faY),acc.getZ(faZ));
-           pc.printf("  MAG: X=%4.1fY=%4.1fZ=%4.1f\r\n", mag.getX(fmX),mag.getY(fmY), mag.getZ(fmZ));
+           pc.printf("FXOSQ8700Q ACC: X=%1.4f   Y=%1.4f   Z=%1.4f", acc.getX(faX),acc.getY(faY),acc.getZ(faZ));
+           pc.printf("  MAG: X=%4.1f   Y=%4.1f   Z=%4.1f\r\n", mag.getX(fmX),mag.getY(fmY), mag.getZ(fmZ));
            gyro.ReadXYZ(gyro_data);
-           pc.printf("FXAS21000  Gyro: X=%6.2fY=%6.2fZ=%6.2f\r\n", gyro_data[0],gyro_data[1], gyro_data[2]);
+           pc.printf("FXAS21000  Gyro: X=%6.2f   Y=%6.2f    Z=%6.2f\r\n", gyro_data[0],gyro_data[1], gyro_data[2]);
+           
+          
+           if(abs(acc.getX(faX)) > 1.5 || abs(acc.getZ(faZ)) > 1.3 || abs(acc.getY(faY)) > 0.1)
+           {
+            
+            Red = 0;
+            Blue = 1;
+            Green = 1;
+
+            } 
+            
+            
+            else{
+                
+                Red = 1;
+                Green = 0;
+                Blue = 1;
+                };
             wait(1.0f);
         }
     }
\ No newline at end of file