ADXL362(acceloremeter)

hi
I am using Adxl 362 to detects free fall by connecting to a buzzer
after the fall the buzzer is still on
and the value of interrupt is 1

How can I write a code to detects free fall and buzz for like 2 seconds and after that will be ready to detect another free fall ?

Is there a way to reset it ?

(deleted)

digitalWrite(slaveSelectPin, LOW);
SPI.transfer(0x0B); // Read
digitalWrite(slaveSelectPin, HIGH);

I am using this code to reset it
but it doesnt work

help

MovieFan1995:
help

share your code if you want us to be able to help

void setup() {

attachInterrupt(digitalPinToInterrupt(2),x, CHANGE);/}

void loop(){
// read all three axis in burst to ensure all measurements correspond to same sample time
xl.readXYZTData(XValue, YValue, ZValue, Temperature);
temp = digitalRead(2);

Serial.print("Int2 is ");
Serial.print(temp);
//Serial.print("\t");

Serial.print("\t");
}

void x(){
Serial.println("Your Friend Has Fallen"); delayMicroseconds(1000);

}

It only detects one free fall

are you using any libraries for the ADXL362? if yes please post link (Github for example) to them as well

YES
here is the link

so from the datasheet:
“Clear interrupts in one of several ways, as follows:
• Reading the STATUS register (Address 0x0B) clears
activity and inactivity interrupts.
• Reading from the data registers. Address 0x08 to
Address 0x0A or Address 0x0E to Address 0x15 clears
the data ready interrupt.
• Reading enough data from the FIFO buffer so that
interrupt conditions are no longer met clears the FIFO
ready, FIFO watermark, and FIFO overrun interrupts”

so I guess you could use the “SPIreadOneRegister” in the ASXL362 library.

something like this in your ISR routine you gave above:

void x(){
Serial.println(“Your Friend Has Fallen”); delayMicroseconds(1000);

xl.SPIreadOneRegister(0x0B);

}

FYI it is generally not good practice to use Serial.print or delays within an ISR routine.

Hope that helps.

Thank you so much
It worked!!