I have an ADXL345 accelerometer hooked up to my Arduino Mega and I am able to read values just fine. Now I want to try to use the tap detector. I have set the following registers:
//Set the device to the highest G-rating, 16g’s
writeTo(DEVICE, REG_DATA_FORMAT, 0x3);
//Set the tap threshold in 16 Gs, ff=16g threshold.
writeTo(DEVICE, REG_THRESH_TAP, 0x2);
//Set the tap axes to all three
writeTo(DEVICE, REG_TAP_AXES, 0x7);
//Set the maximum tap duration. 1 LSB == 625 usec
writeTo(DEVICE, REG_DUR, 0x80);
attachInterrupt(0, onTapDetected, CHANGE);
//Clear any interupts
readFrom(DEVICE, REG_INT_SOURCE, 1, buff);
//Set up tap detection interrupt by setting D6 high (zero based, so left shift 0x1 by 6 places to reach 7th bit
writeTo(DEVICE, REG_INT_ENABLE, 0x20);
My interrupt works if I just manually move the connection on the breadboard to high, but it never seems to raised by the ADXL345. I don’t know if the problem is that I haven’t properly set the ADXL345 registers up and it is never raising the interrupt, or whether I haven’t wired it properly. I have tried a bunch of values for the threshold and max duration, but nothing seems to change the behavior. I have been over and over the datasheet, and these values seem like all I need to set.
Do I need to do anything other than take a connection straight from Int1 on the ADXL345 to Pin2 on the Arduino? Does it matter that the ADXL345 is a 3.3v device, like maybe only raising the voltage to 3.3v isn’t enough to trigger the interrupt?