File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ LPS22HB - Pressure interrupt
3
+ This example config the INTERRUPT pin of the sensor
4
+ that allows to use interrupts attached to that pin
5
+ and do something, for example light up a LED
6
+
7
+ This example code is in the public domain.
8
+ */
9
+
10
+ #include < Arduino_LPS22HB.h>
11
+
12
+ void setup () {
13
+ // put your setup code here, to run once:
14
+ Serial.begin (9600 );
15
+ while (!Serial);
16
+
17
+ if (!BARO.begin ()) {
18
+ Serial.println (" Failed BAro" );
19
+ while (1 );
20
+ }
21
+
22
+ // Config for the Interrupts and the Interrupt pin
23
+ BARO.enableInterruptPin (); // Enables ic's pin
24
+ BARO.setOpenDrain (); // Config ic's pin to be in a open drain
25
+ BARO.setActiveHigh (); // High means interrupt
26
+ BARO.enableHighPressureInterrupt (); // We set to interrupt when the pressure is higher than the Threshold setThreshold()
27
+ }
28
+
29
+ void loop () {
30
+ // put your main code here, to run repeatedly:
31
+ BARO.setThreshold (16 ); // +-Interrupt threshold = value /16 , in this case 16/16 = 1 hPa
32
+ Serial.println (BARO.readPressure ()); // The interrupt is updated when it has been read
33
+ delay (1500 );
34
+
35
+ BARO.setThreshold (20000 ); // +-Interrupt threshold = value /16 , in this case 20000/16 = 125 hPa
36
+ Serial.println (BARO.readPressure ()); // The interrupt is updated when it has been read
37
+ delay (1500 );
38
+ }
You can’t perform that action at this time.
0 commit comments