STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
example2_interrupt.ino
Go to the documentation of this file.
1/*
2 example2-interrupt
3
4 This example shows the basic settings and functions for retrieving accelerometer
5 data. In addition we're setting the data ready signal to interrupt pin one in an
6 active high configuration and show additional ways in which the interrupts
7 can be configured.
8
9 Please refer to the header file for more possible settings, found here:
10 ..\SparkFun_6DoF_ISM330DHCX_Arduino_Library\src\sfe_ism330dhcx_defs.h
11
12 Written by Elias Santistevan @ SparkFun Electronics, August 2022
13
14 Product:
15
16 6DoF: https://www.sparkfun.com/products/19764
17 9DoF: https://www.sparkfun.com/products/19895
18
19 Repository:
20
21 https://github.com/sparkfun/SparkFun_6DoF_ISM330DHCX_Arduino_Library
22
23 SparkFun code, firmware, and software is released under the MIT
24 License (http://opensource.org/licenses/MIT).
25*/
26
27#include <Wire.h>
28#include "STAR_ISM330DH.h"
29
30// Structs for X,Y,Z data
33
34
35// Interrupt pin
36byte interrupt_pin = D1;
37
38void setup(){
39
40 // Set the interrupt to INPUT
42 Serial.begin(115200);
43
44 Wire.begin();
45
46 if( !myISM.begin() ){
47 Serial.println("Did not begin.");
48 while(1);
49 }
50
51 // Reset the device to default settings. This is helpful if you're doing multiple
52 // uploads testing different settings.
53 myISM.deviceReset();
54
55 // Wait for it to finish reseting
56 while( !myISM.getDeviceReset() ){
57 delay(1);
58 }
59
60 Serial.println("Reset.");
61 Serial.println("Applying settings.");
62 delay(100);
63
64 myISM.setDeviceConfig();
65 myISM.setBlockDataUpdate();
66
67 // Set the output data rate and precision of the accelerometer
68 myISM.setAccelDataRate(ISM_XL_ODR_104Hz);
69 myISM.setAccelFullScale(ISM_4g);
70
71 // Turn on the accelerometer's filter and apply settings.
72 myISM.setAccelFilterLP2();
73 myISM.setAccelSlopeFilter(ISM_LP_ODR_DIV_100);
74
75 // Set the accelerometer's status i.e. the data ready to interrupt one.
76 // Commented out just below is the function to send the data ready
77 // to interrupt two.
78
79 myISM.setAccelStatustoInt1();
80 //myISM.setAccelStatustoInt2();
81
82
83 // We can just as easily set the gyroscope's data read signal to either interrupt
84
85 //myISM.setGyroStatustoInt1();
86 //myISM.setGyroStatustoInt2();
87
88
89 // Uncommenting the function call below will change the interrupt to
90 // active LOW instead of HIGH.
91
92 //myISM.setPinMode();
93
94 // This function call will modify which "events" trigger an interrupt. No
95 // argument has been given, please refer to the datasheet for more
96 // information.
97
98 // myISM.setIntNotification(uint8_t val);
99}
100
101void loop(){
102
104 myISM.getAccel(&accelData);
105 Serial.print("Accelerometer: ");
106 Serial.print("X: ");
107 Serial.print(accelData.xData);
108 Serial.print(" ");
109 Serial.print("Y: ");
110 Serial.print(accelData.yData);
111 Serial.print(" ");
112 Serial.print("Z: ");
113 Serial.print(accelData.zData);
114 Serial.println(" ");
115 }
116
117 delay(100);
118}
119
static SerialStub Serial
Definition Arduino.h:128
#define INPUT
Definition Arduino.h:21
int digitalRead(int)
Definition Arduino.h:50
#define HIGH
Definition Arduino.h:19
void pinMode(int, int)
Definition Arduino.h:46
void delay(int ms)
STAR_ISM330DH — improved fork of SparkFun's SparkFun_6DoF_ISM330DHCX_Arduino_Library.
ISM330DH myISM
void setup()
byte interrupt_pin
void loop()
static sfe_ism_data_t accelData
Definition main.cpp:9
#define ISM_LP_ODR_DIV_100
#define ISM_4g
#define ISM_XL_ODR_104Hz