Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:955628fdbf95
- Child:
- 1:813b3c3eb644
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Apr 13 06:39:17 2015 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "LPS25H.h"
+
+I2C i2c(I2C_SDA, I2C_SCL);
+
+DigitalOut myled(LED1);
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+LPS25H lps25h(i2c);
+
+int main(){
+
+ double p, t, h, p0;
+
+ // Set reference value
+ p0 = (double)lps25h.pressure()/4096.0;
+ pc.printf("Set p0 = %7.2fhPa\n", p0);
+
+ while (1) {
+ // Read pressure & temperature
+ p = (double)lps25h.pressure()/4096.0;
+ t = 42.5 + (double)lps25h.temperature()/480.0;
+
+ // Calculate altitude
+ h = (pow((p0/p),0.1902)-1.0)*(t+273.15)/0.0065;
+
+ // Display result
+ pc.printf("height = %4.1fm, pressure = %7.2fhPa, temperature = %5.2fC\n", h, p, t);
+ myled = !myled;
+ wait(1.0);
+ }
+
+}
+
+