-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from caternuson/iss10_shake
Add shake
- Loading branch information
Showing
3 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
examples/adafruit_lsm6ds33_shake/adafruit_lsm6ds33_shake.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Basic demo for accelerometer/gyro readings from Adafruit LSM6DS33 | ||
|
||
#include <Adafruit_LSM6DS33.h> | ||
|
||
// For SPI mode, we need a CS pin | ||
#define LSM_CS 10 | ||
// For software-SPI mode we need SCK/MOSI/MISO pins | ||
#define LSM_SCK 13 | ||
#define LSM_MISO 12 | ||
#define LSM_MOSI 11 | ||
|
||
Adafruit_LSM6DS33 lsm6ds33; | ||
void setup(void) { | ||
Serial.begin(115200); | ||
while (!Serial) | ||
delay(10); // will pause Zero, Leonardo, etc until serial console opens | ||
|
||
Serial.println("Adafruit LSM6DS33 shake test!"); | ||
|
||
if (!lsm6ds33.begin_I2C()) { | ||
// if (!lsm6ds33.begin_SPI(LSM_CS)) { | ||
// if (!lsm6ds33.begin_SPI(LSM_CS, LSM_SCK, LSM_MISO, LSM_MOSI)) { | ||
Serial.println("Failed to find LSM6DS33 chip"); | ||
while (1) { | ||
delay(10); | ||
} | ||
} | ||
|
||
Serial.println("LSM6DS33 Found!"); | ||
|
||
// enable shake detection | ||
lsm6ds33.enableWakeup(true); | ||
} | ||
|
||
void loop() { | ||
// check for shake | ||
if (lsm6ds33.shake()) { | ||
Serial.println("SHAKE!"); | ||
} | ||
} |