You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Redistribution and use in source and binary forms, with or without
16
+
modification, are permitted provided that the following conditions are met:
17
+
18
+
Redistributions of source code must retain the above copyright
19
+
notice, this list of conditions and the following disclaimer.
20
+
21
+
Redistributions in binary form must reproduce the above copyright
22
+
notice, this list of conditions and the following disclaimer in the
23
+
documentation and/or other materials provided with the distribution.
24
+
25
+
Neither the name of the copyright holder nor the names of the
26
+
contributors may be used to endorse or promote products derived from
27
+
this software without specific prior written permission.
28
+
29
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32
+
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
33
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
39
+
40
+
The information provided is believed to be accurate and reliable.
41
+
The copyright holder assumes no responsibility for the consequences of use
42
+
of such information nor for any infringement of patents or
43
+
other rights of third parties which may result from its use.
44
+
No license is granted by implication or otherwise under any patent or
45
+
patent rights of the copyright holder.
46
46
*/
47
47
48
-
#include"NineAxesMotion.h"//Contains the bridge code between the API and the Arduino Environment
48
+
#include"NineAxesMotion.h"//Contains the bridge code between the API and the Arduino Environment
49
49
#include<Wire.h>
50
50
51
-
NineAxesMotion mySensor; //Object that for the sensor
52
-
bool intDetected = false; //Flag to indicate if an interrupt was detected
53
-
int threshold = 5; //At a Range of 4g, the threshold is set at 39.05mg or 0.3830m/s2. This Range is the default for NDOF Mode
54
-
int duration = 1; //At a filter Bandwidth of 62.5Hz, the duration is 8ms. This Bandwidth is the default for NDOF Mode
55
-
bool anyMotion = true; //To know which interrupt was triggered
51
+
NineAxesMotion mySensor; //Object that for the sensor
52
+
bool intDetected = false; //Flag to indicate if an interrupt was detected
53
+
int threshold = 5; //At a Range of 4g, the threshold is set at 39.05mg or 0.3830m/s2. This Range is the default for NDOF Mode
54
+
int duration = 1; //At a filter Bandwidth of 62.5Hz, the duration is 8ms. This Bandwidth is the default for NDOF Mode
55
+
bool anyMotion = true; //To know which interrupt was triggered
56
+
57
+
int InterruptPin = 2; // Pin D2 is connected to the INT LED
56
58
57
59
voidsetup() //This code is executed once
58
60
{
59
61
//Peripheral Initialization
60
-
Serial.begin(115200); //Initialize the Serial Port to view information on the Serial Monitor
61
-
I2C.begin();//Initialize I2C communication to the let the library communicate with the sensor.
62
+
Serial.begin(9600);//Initialize the Serial Port to view information on the Serial Monitor
63
+
Wire.begin();//Initialize I2C communication to the let the library communicate with the sensor.
62
64
//Sensor Initialization
63
65
Serial.println("Please wait. Initialization in process.");
64
-
mySensor.initSensor();//The I2C Address can be changed here inside this function in the library
65
-
mySensor.setOperationMode(OPERATION_MODE_NDOF); //Can be configured to other operation modes as desired
66
-
mySensor.setUpdateMode(MANUAL); //The default is AUTO. Changing to manual requires calling the relevant update functions prior to calling the read functions
66
+
mySensor.initSensor();//The I2C Address can be changed here inside this function in the library
67
+
mySensor.setOperationMode(OPERATION_MODE_NDOF); //Can be configured to other operation modes as desired
68
+
mySensor.setUpdateMode(MANUAL); //The default is AUTO. Changing to manual requires calling the relevant update functions prior to calling the read functions
67
69
//Setting to MANUAL requires lesser reads to the sensor
68
70
69
-
attachInterrupt(INT_PIN, motionISR, RISING); //Attach the interrupt to the Interrupt Service Routine for a Rising Edge. Change the interrupt pin depending on the board
71
+
72
+
attachInterrupt(digitalPinToInterrupt(InterruptPin), motionISR, RISING); //Attach the interrupt to the Interrupt Service Routine for a Rising Edge. Change the interrupt pin depending on the board
70
73
71
74
//Setup the initial interrupt to trigger at No Motion
0 commit comments