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:7f9aa4ca18c2, committed 2019-11-26
- Comitter:
- bjanquart
- Date:
- Tue Nov 26 02:25:19 2019 +0000
- Commit message:
- Project;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LSM6DS3.lib Tue Nov 26 02:25:19 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/5hel2l2y/code/LSM6DS3/#ed14e6196255
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Nov 26 02:25:19 2019 +0000
@@ -0,0 +1,62 @@
+// LSM6DS3 Demo
+
+#include "mbed.h"
+#include "LSM6DS3.h"
+
+LSM6DS3 accel(D4, D5);
+
+ DigitalOut led(D13);
+Serial pc(USBTX, USBRX);
+
+float xvalues[25], yvalues[25], zvalues[25], x_sum, y_sum, z_sum, x_avg, y_avg, z_avg;
+bool fall_waiting = true;
+
+int main()
+{
+ accel.begin(accel.G_SCALE_2000DPS, accel.A_SCALE_8G,
+ accel.G_ODR_1660, accel.A_ODR_6660);
+ led = 1;
+
+ // fill array initial
+ for (int i = 0; i < 25; ++i){
+ accel.readAccel();
+ xvalues[i] = accel.ax;
+ yvalues[i] = accel.ay;
+ zvalues[i] = accel.az;
+ }
+
+
+ while (fall_waiting)
+ {
+ accel.readAccel();
+ xvalues[24] = accel.ax;
+ yvalues[24] = accel.ay;
+ zvalues[24] = accel.az;
+ // for loop that copies down the array
+ for (int i = 1; i < 25; ++i){
+
+ xvalues[i - 1] = xvalues[i];
+ yvalues[i - 1] = yvalues[i];
+ zvalues[i - 1] = zvalues[i];
+ }
+ // clear the sum values
+ x_sum = 0;
+ y_sum = 0;
+ z_sum = 0;
+ // average
+ for(int in = 0; in < 25; ++in){
+ x_sum += xvalues[in];
+ y_sum += yvalues[in];
+ z_sum += zvalues[in];
+ }
+ x_avg = x_sum / 25;
+ y_avg = y_sum / 25;
+ z_avg = z_sum / 25;
+
+ if(xvalues[24] > x_avg + 1 || yvalues[24] > y_avg + 1 || zvalues[24] > z_avg + 1){
+ led = 0;
+ fall_waiting = false;
+ }
+ }
+}
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Nov 26 02:25:19 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file