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.
Dependencies: mbed MMA8452Q SDSD
Diff: main.cpp
- Revision:
- 1:bee807884a79
- Parent:
- 0:d1f1b7e3b561
- Child:
- 2:8e2c44115ce0
--- a/main.cpp Tue Nov 16 15:09:21 2021 +0000
+++ b/main.cpp Tue Nov 16 15:24:46 2021 +0000
@@ -10,6 +10,9 @@
#define READTIME 0.2
#define WRITETIME 1.0
+DigitalOut Led1(LED1);
+DigitalOut Led2(LED2);
+DigitalOut Led3(LED3);
MMA8452Q accel(p28,p27,0x1D);
Serial pc(USBTX,USBRX);
@@ -22,7 +25,7 @@
{
accX_g = accel.readX();
accY_g = accel.readY();
- accZ_g = accel.readZ();
+ accZ_g = accel.readZ();
}
int main()
@@ -42,7 +45,22 @@
serial_reporting.reset();
serial_reporting.start();
pc.printf("X,Y,Z [Gs]: %5.2f, %5.2f, %5.2f\r\n",accX_g,accY_g,accZ_g);
+ if (accX_g>accY_g && accX_g>accZ_g) {
+ Led1=1;
+ Led2=0;
+ Led3=0;
+ }
+ if (accY_g>accX_g && accX_g>accZ_g) {
+ Led1=0;
+ Led2=1;
+ Led3=0;
+ }
+ if (accZ_g>accX_g && accX_g>accY_g) {
+ Led1=0;
+ Led2=0;
+ Led3=1;
+ }
}
}
-
-}
\ No newline at end of file
+
+}
