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: ADXL362 MPL3115A2 mbed
Diff: main.cpp
- Revision:
- 0:9a45e4f07b10
- Child:
- 1:2630bf98c8fe
- Child:
- 2:c322c1331eaa
diff -r 000000000000 -r 9a45e4f07b10 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Mar 02 17:49:50 2018 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "MPL3115A2.h"
+#include "ADXL362.h"
+#include <string>
+#include <math.h>
+
+
+ADXL362 ADXL362(PA_0,PA_7,PA_6,PA_1);
+Serial pc(SERIAL_TX, SERIAL_RX);
+DigitalOut myled(LED1);
+DigitalOut powerpin(PA_8);
+
+// Selects SDA as I2C1_SDA on pin PB_7
+// Selects SCL on I2C1_SCL on pin PB_6
+// The I2C address of the pressure sensor is fixed at 0x60.
+MPL3115A2 pressure_sensor(PB_7,PB_6,0x60);
+
+int main() {
+ int8_t a1, a2, a;
+ double p, t;
+ double v = 0.0;
+ int cnt = 0;
+ myled = 0;
+ powerpin = 0;
+
+ wait_ms(600); // we need to wait at least 500ms after ADXL362 reset
+ ADXL362.set_mode(ADXL362::MEASUREMENT);
+
+
+ while(1)
+ {
+ if(powerpin)
+ {
+ myled = 1;
+ a1=ADXL362.scanz_u8();
+ p=pressure_sensor.getPressure();
+ t=pressure_sensor.getTemperature();
+
+ pc.printf("temp_%d = %f C ; pressure_%d = %f \n\r Pa",cnt,t,cnt,p);
+ cnt++;
+
+ wait_ms(100);
+ a2=ADXL362.scanz_u8();
+ a = a1 - a2;
+
+ v = v + double(a) * 0.1;
+ pc.printf(" velocity = %f \n\r",v);
+ }
+ else
+ {
+ myled = 0;
+ }
+}
+}
+
\ No newline at end of file