mikeflores2000 AT&T MultiTech M2X Exercises book
Dependencies: M2XStreamClient MMA8451Q SocketModem jsonlite mbed
Fork of M2X_MTS_Accel by
Diff: main.cpp
- Revision:
- 4:8157d7b1cd01
- Parent:
- 3:3aa188afd648
--- a/main.cpp Fri Aug 22 07:42:15 2014 +0000 +++ b/main.cpp Thu Sep 04 21:10:40 2014 +0000 @@ -120,18 +120,21 @@ y = acc.getAccY(); z = acc.getAccZ(); printf("Accel X: %1.2f, Y: %1.2f, Z: %1.2f\n\r", x, y, z); + // Calculate pitch and roll. Find the maximum tilt angle. float pitch = atan(x / sqrt(y * y + z * z)); float roll = atan(y / sqrt(x * x + z * z)); float maxTilt = max(abs(roll), abs(pitch)) * 180.0 / 3.14159; -printf("pitch: %5.1f roll: %5.1f maxTilt: %5.1f\n\r", +printf("Pitch: %5.1f roll: %5.1f maxTilt: %5.1f\n\r", pitch, roll, maxTilt); +wait(10); +printf("\n"); // If the maximum title is over 20 degrees, then send // data to stream if (maxTilt > 20) { ret = m2xClient.post(feed, stream, maxTilt); -printf("send() returned %d\r\n", ret); -wait(1); +printf("maxTilt EXCEEDED 20 !!!! send() returned %d\r\n", ret); +wait(10); } } } \ No newline at end of file