Skip to content

Commit 9d44b3e

Browse files
authored
Add files via upload
1 parent b713ba5 commit 9d44b3e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)