Skip to content

Commit fe5c711

Browse files
authored
Add files via upload
1 parent 0b15600 commit fe5c711

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

examples/Arduino/Example4_WakeOnMotion/Example4_WakeOnMotion.ino

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@
4242
volatile bool isrFired = false;
4343
volatile bool sensorSleep = false;
4444
volatile bool canToggle = false;
45-
unsigned int WOM_threshold=200;
45+
unsigned int WOM_threshold=255;
46+
double lastTrigerred;
4647

4748
void setup() {
4849

4950
pinMode(INT_PIN, INPUT_PULLUP); // Using a pullup b/c ICM-20948 Breakout board has an onboard pullup as well and we don't want them to compete
5051
attachInterrupt(digitalPinToInterrupt(INT_PIN), icmISR, FALLING); // Set up a falling interrupt
5152

5253
pinMode(LED_PIN, OUTPUT);
53-
digitalWrite(LED_PIN, !sensorSleep);
54+
digitalWrite(LED_PIN, LOW);
5455

5556
SERIAL_PORT.begin(115200);
5657
while(!SERIAL_PORT){};
@@ -215,7 +216,9 @@ void loop() {
215216
isrFired = false;
216217
myICM.getAGMT(); // get the A, G, M, and T readings
217218
// printScaledAGMT( myICM.agmt); // This function takes into account the sclae settings from when the measurement was made to calculate the values with units
218-
SERIAL_PORT.println(F("Shock detected"));
219+
SERIAL_PORT.println(F("Shock detected"));
220+
digitalWrite(LED_PIN, HIGH);
221+
lastTrigerred=millis();
219222
delay(30);
220223
myICM.clearInterrupts(); // This would be efficient... but not compatible with Uno
221224
}
@@ -231,7 +234,8 @@ void loop() {
231234
// 2. use the pulse-based interrupt in ICM settings (set cfgIntLatch to false)
232235
// 3. use a microcontroller with nestable interrupts
233236
// 4. clear the interrupts often
234-
237+
if(millis()-lastTrigerred>1000)
238+
digitalWrite(LED_PIN, LOW);;
235239
}
236240

237241
void icmISR( void ){

0 commit comments

Comments
 (0)