File tree 1 file changed +7
-7
lines changed
examples/AccelerometerTap
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 1
- /*
1
+ /*
2
2
Arduino LSM6DS3 - Accelerometer Tap
3
3
4
4
this code is to detect tap
@@ -18,24 +18,24 @@ void setup() {
18
18
delay (3000 ); // wait for 3 sec and check if it can be initialized again
19
19
}
20
20
}
21
- float tapThreshold = 0.05 ; // 0.05 g acceleration in some direction is considered as tap. it can be change for the required sensitivity.
21
+ float tapThreshold = 0.05 ; // 0.05 g acceleration in some direction is considered as tap. it can be changed for the required sensitivity.
22
22
23
- int down = 3 ; // signifying the direction of which is facing downward 1 for x axis ; 2 for y axis ; 3 for z axis;
23
+ int down = 3 ; // signifying the direction of which is facing downward 1 for x axis; 2 for y axis; 3 for z axis;
24
24
25
25
void loop () {
26
26
float x, y, z;
27
27
if (IMU.accelerationAvailable ()) {
28
28
IMU.readAcceleration (x, y, z);
29
-
29
+
30
30
if ((x > tapThreshold || x < -tapThreshold) && down != 1 ) {
31
31
Serial.println (" Tap detected across X-axis" );
32
32
}
33
-
33
+
34
34
if ((y > tapThreshold || y < -tapThreshold) && down != 2 ) {
35
35
Serial.println (" Tap detected across Y-axis" );
36
36
}
37
-
38
- if ((z > tapThreshold || z < -tapThreshold)&& down != 3 ) {
37
+
38
+ if ((z > tapThreshold || z < -tapThreshold) && down != 3 ) {
39
39
Serial.println (" Tap detected across Z-axis" );
40
40
}
41
41
}
You can’t perform that action at this time.
0 commit comments