The accelerometer (LSM6DSL) on the BerryIMUv3 has built in double tap detection, which makes it very easy to detect double taps without the need for any fancy code.
When the LSM6DSL detects a double tap, it can fire an interrupt pin on the BerryIMUv3. We will use a Raspberry Pi to monitor the interrupt pin and turn a LED off and on when a double-tap is detected.
Double-Tap event recognition has special registers which control tap recognition functionality, these are the tap threshold and the Shock, Quiet and Duration time windows
The Raspberry Pi will configure the BerryIMUv3 for double tap recognition. It will also monitor for double taps, which will be used to turn a LED on and off.
INT1 On the BerryIMUv3 will go high when a double tap is detected.
GPIO18 (physical pin 12) on the Raspberry Pi will be used to monitor INT1, using an interrupt.
GPIO20 (physical pin 28) will be used to drive the LED.
The resister below is 330 Ohms
Here is the hock up diagrams
We will cover specific code which relates to double-tap recognition.
Line 38, LSM6DSL_TAP_CFG is used to enable tap recognition on the X, Y, Z directions. It is also used to enable the interrupt function for double-tap recognition.
Line 39 , LSM6DSL_TAP_THS_6D is used to set the tap thresholds. a lower value will result in softer taps being detected.
Line 40 , LSM6DS_INT_DUR2 is used to set the duration, quiet and shock time window. A larger duration will result in a longer time between 1st and 2nd tap.
Line 41, LSM6DSL_WAKE_UP_THS. Set the left most bit to enable double tap recognition.
Line 42, LSM6DSL_MD1_CFG is used to set which interrupt pin ont he BerryIMUv3 is used. In this instance, it is set to INT1.
Comments