
92
Dependencies: ADXL362 ATParser MPL3115A2 TSL2561 mbed
Fork of Lab91 by
Revision 0:9a45e4f07b10, committed 2018-03-02
- Comitter:
- fanbsun
- Date:
- Fri Mar 02 17:49:50 2018 +0000
- Child:
- 1:2630bf98c8fe
- Child:
- 2:c322c1331eaa
- Commit message:
- lab7
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ADXL362.lib Fri Mar 02 17:49:50 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/teams/AnalogDevices/code/ADXL362/#ae171c032dc0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MPL3115A2.lib Fri Mar 02 17:49:50 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/teams/MSS/code/MPL3115A2/#12223b4c88b1
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Mar 02 17:49:50 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/5571c4ff569f \ No newline at end of file