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.
Fork of mbed_test_fastest_rate-bo by
sensors_scheduled.cpp@1:3d1239d55050, 2014-02-09 (annotated)
- Committer:
- mja054
- Date:
- Sun Feb 09 02:18:55 2014 +0000
- Revision:
- 1:3d1239d55050
- Child:
- 2:ca095bd51302
these changes
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mja054 | 1:3d1239d55050 | 1 | #include "mbed.h" |
| mja054 | 1:3d1239d55050 | 2 | #include "MMA8451Q.h" |
| mja054 | 1:3d1239d55050 | 3 | #include "MAG3110.h" |
| mja054 | 1:3d1239d55050 | 4 | #include "SLCD.h" |
| mja054 | 1:3d1239d55050 | 5 | #include "TSISensor.h" |
| mja054 | 1:3d1239d55050 | 6 | |
| mja054 | 1:3d1239d55050 | 7 | #define MMA8451_I2C_ADDRESS (0x1d << 1) |
| mja054 | 1:3d1239d55050 | 8 | #define MAG3110_I2C_ADDRESS (0x0e << 1) |
| mja054 | 1:3d1239d55050 | 9 | |
| mja054 | 1:3d1239d55050 | 10 | Serial pc(USBTX, USBRX); |
| mja054 | 1:3d1239d55050 | 11 | MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); |
| mja054 | 1:3d1239d55050 | 12 | MAG3110 mag(PTE25, PTE24, MAG3110_I2C_ADDRESS); |
| mja054 | 1:3d1239d55050 | 13 | AnalogIn lightSensor(PTE22); |
| mja054 | 1:3d1239d55050 | 14 | DigitalOut myled(LED1); |
| mja054 | 1:3d1239d55050 | 15 | DigitalOut myled2(LED2); |
| mja054 | 1:3d1239d55050 | 16 | Timer t; |
| mja054 | 1:3d1239d55050 | 17 | SLCD slcd; |
| mja054 | 1:3d1239d55050 | 18 | TSISensor tsi; |
| mja054 | 1:3d1239d55050 | 19 | float accel, magma, light, touch; |
| mja054 | 1:3d1239d55050 | 20 | |
| mja054 | 1:3d1239d55050 | 21 | int main() { |
| mja054 | 1:3d1239d55050 | 22 | t.reset(); |
| mja054 | 1:3d1239d55050 | 23 | t.start(); |
| mja054 | 1:3d1239d55050 | 24 | while (true){ |
| mja054 | 1:3d1239d55050 | 25 | int time = t.read_ms(); |
| mja054 | 1:3d1239d55050 | 26 | if ( time%10 == 0){ |
| mja054 | 1:3d1239d55050 | 27 | accel = acc.getAccX();} |
| mja054 | 1:3d1239d55050 | 28 | if (time%17 == 0){ |
| mja054 | 1:3d1239d55050 | 29 | magma= mag.readVal(MAG_OUT_X_MSB);} |
| mja054 | 1:3d1239d55050 | 30 | if(time%25 == 0){ |
| mja054 | 1:3d1239d55050 | 31 | light = lightSensor.read();} |
| mja054 | 1:3d1239d55050 | 32 | if (time%32 == 0){ |
| mja054 | 1:3d1239d55050 | 33 | touch = tsi.readPercentage();} |
| mja054 | 1:3d1239d55050 | 34 | pc.printf(" acc = %f, mag = %f,light = %f,touch = %f\n", accel, magma, light, touch); |
| mja054 | 1:3d1239d55050 | 35 | } |
| mja054 | 1:3d1239d55050 | 36 | t.stop(); |
| mja054 | 1:3d1239d55050 | 37 | } |
