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 1:737fa48a7c0c, committed 2018-02-22
- Comitter:
- fanbsun
- Date:
- Thu Feb 22 20:58:06 2018 +0000
- Parent:
- 0:1ca806626aba
- Commit message:
- vd
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Feb 22 15:49:12 2018 +0000
+++ b/main.cpp Thu Feb 22 20:58:06 2018 +0000
@@ -1,5 +1,7 @@
#include "mbed.h"
#include "ADXL362.h"
+#include <stdlib.h>
+
// Interface pulled from ADXL362.cpp
// ADXL362::ADXL362(PinName CS, PinName MOSI, PinName MISO, PinName SCK) :
@@ -15,6 +17,15 @@
adxl362.set_mode(ADXL362::MEASUREMENT);
adxl362_reg_print(0, 3);
+
+ adx1362_knock_detect();
+
+
+
+
+
+
+
return(0);
}
@@ -36,3 +47,41 @@
return(-1);
}
}
+
+void adx1362_knock_detect()
+{
+ int8_t x1,y1,z1,x2,y2,z2,x,y,z;
+ while(1)
+ {
+
+ while(1)
+ {
+ x1=adxl362.scanx_u8();
+ y1=adxl362.scany_u8();
+ z1=adxl362.scanz_u8();
+ wait_ms(100);
+ x2=adxl362.scanx_u8();
+ y2=adxl362.scany_u8();
+ z2=adxl362.scanz_u8();
+
+ x=abs(x1 - x2);
+ y=abs(y1 - y2);
+ z=abs(z1 - z2);
+
+ if (x>10 || y>10 || z>10)
+ break;
+
+ printf("x = %d y = %d z = %d\r\n",x,y,z);
+ wait_ms(100);
+ }
+
+ myled = 1;
+ wait(2);
+
+ }
+
+
+
+
+
+
\ No newline at end of file