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.
main.cpp@1:a1664788d34a, 2020-06-03 (annotated)
- Committer:
- vermaelen
- Date:
- Wed Jun 03 00:36:56 2020 +0000
- Revision:
- 1:a1664788d34a
- Parent:
- 0:c188fa46ae96
base
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| vermaelen | 0:c188fa46ae96 | 1 | #include "mbed.h" |
| vermaelen | 0:c188fa46ae96 | 2 | #include "MMA8451Q.h" |
| vermaelen | 0:c188fa46ae96 | 3 | |
| vermaelen | 1:a1664788d34a | 4 | #define I2C_ADDRESS (0x1d<<1) |
| vermaelen | 0:c188fa46ae96 | 5 | |
| vermaelen | 0:c188fa46ae96 | 6 | int main(void) |
| vermaelen | 0:c188fa46ae96 | 7 | { |
| vermaelen | 1:a1664788d34a | 8 | MMA8451Q acc(PTE25, PTE24, I2C_ADDRESS); |
| vermaelen | 1:a1664788d34a | 9 | float x, z; |
| vermaelen | 0:c188fa46ae96 | 10 | printf("MMA8451 ID: %d\n", acc.getWhoAmI()); |
| vermaelen | 1:a1664788d34a | 11 | while (1) { |
| vermaelen | 1:a1664788d34a | 12 | x = acc.getAccX(); |
| vermaelen | 1:a1664788d34a | 13 | z = acc.getAccZ(); |
| vermaelen | 1:a1664788d34a | 14 | printf("X: %1.2f, Z: %1.2f\r\n", x, z); |
| vermaelen | 1:a1664788d34a | 15 | wait(0.1); |
| vermaelen | 0:c188fa46ae96 | 16 | } |
| vermaelen | 0:c188fa46ae96 | 17 | } |