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: ADXL362 mbed MPL3115A2
Revision 15:5ce9c63e7da2, committed 2018-02-23
- Comitter:
- htdoughe
- Date:
- Fri Feb 23 02:53:00 2018 +0000
- Parent:
- 14:0c2659ce7a8a
- Child:
- 16:993757c8b398
- Commit message:
- added knock count
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Feb 22 21:36:00 2018 +0000
+++ b/main.cpp Fri Feb 23 02:53:00 2018 +0000
@@ -145,6 +145,7 @@
initx=adxl362.scanx_u8();
inity=adxl362.scany_u8();
initz=adxl362.scanz_u8();
+ int count = 0;
while(1) {
//get the values of x, y, and z to test for a knock
@@ -154,6 +155,8 @@
//if x, y, or z vary from baseline by at least 3, a knock has occured.
if(x > initx+2 || y > inity+2 || z > initz+2 || x > initx-2 || y > inity-2 || z > initz-2){
led1 = 1;
+ count++;
+ printf("number of knocks: %d\r\n", count);
wait_ms(2000);
led1 = 0;
}