An FRDM example using Serial, Accelerometer and Touch Sensor.
Dependencies: MMA8451Q TSI mbed
main.cpp@4:5a98b723b199, 2014-09-12 (annotated)
- Committer:
- dbaba
- Date:
- Fri Sep 12 08:15:40 2014 +0000
- Revision:
- 4:5a98b723b199
- Parent:
- 1:32eacc4f6beb
initial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 0:f59179afee57 | 1 | #include "mbed.h" |
dbaba | 4:5a98b723b199 | 2 | #include "MMA8451Q.h" |
dbaba | 4:5a98b723b199 | 3 | #include "TSISensor.h" |
dbaba | 4:5a98b723b199 | 4 | |
dbaba | 4:5a98b723b199 | 5 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
emilmont | 0:f59179afee57 | 6 | |
emilmont | 0:f59179afee57 | 7 | DigitalOut myled(LED_GREEN); |
dbaba | 4:5a98b723b199 | 8 | Serial serial(USBTX,USBRX); |
dbaba | 4:5a98b723b199 | 9 | MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); |
dbaba | 4:5a98b723b199 | 10 | TSISensor tsi; |
emilmont | 0:f59179afee57 | 11 | |
emilmont | 0:f59179afee57 | 12 | int main() { |
dbaba | 4:5a98b723b199 | 13 | |
emilmont | 0:f59179afee57 | 14 | int i=0; |
emilmont | 0:f59179afee57 | 15 | |
emilmont | 1:32eacc4f6beb | 16 | while (true) { |
dbaba | 4:5a98b723b199 | 17 | //wait(0.5); |
dbaba | 4:5a98b723b199 | 18 | serial.printf("{\"i\":%d,\"x\":%5.2f,\"y\":%5.2f,\"z\":%5.2f, \"tsi\":%5.2f}\n", |
dbaba | 4:5a98b723b199 | 19 | i, acc.getAccX(), acc.getAccY(), acc.getAccZ(), tsi.readPercentage()); |
emilmont | 0:f59179afee57 | 20 | i++; |
emilmont | 0:f59179afee57 | 21 | myled = !myled; |
emilmont | 0:f59179afee57 | 22 | } |
emilmont | 0:f59179afee57 | 23 | } |