File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
examples/AccelerometerTap Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 1- /*
1+ /*
22 Arduino LSM6DS3 - Accelerometer Tap
33
44 this code is to detect tap
@@ -18,24 +18,24 @@ void setup() {
1818 delay (3000 ); // wait for 3 sec and check if it can be initialized again
1919 }
2020}
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.
2222
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;
2424
2525void loop () {
2626 float x, y, z;
2727 if (IMU.accelerationAvailable ()) {
2828 IMU.readAcceleration (x, y, z);
29-
29+
3030 if ((x > tapThreshold || x < -tapThreshold) && down != 1 ) {
3131 Serial.println (" Tap detected across X-axis" );
3232 }
33-
33+
3434 if ((y > tapThreshold || y < -tapThreshold) && down != 2 ) {
3535 Serial.println (" Tap detected across Y-axis" );
3636 }
37-
38- if ((z > tapThreshold || z < -tapThreshold)&& down != 3 ) {
37+
38+ if ((z > tapThreshold || z < -tapThreshold) && down != 3 ) {
3939 Serial.println (" Tap detected across Z-axis" );
4040 }
4141 }
You can’t perform that action at this time.
0 commit comments