sadf
Dependencies: LSM9DS1_Library_cal XBee mbed
Fork of FinalProject by
Diff: main.cpp
- Revision:
- 3:2d6ff72599f1
- Parent:
- 2:ab7b95fb52aa
--- a/main.cpp Sun Apr 23 19:26:07 2017 +0000 +++ b/main.cpp Mon Apr 24 04:05:46 2017 +0000 @@ -1,5 +1,6 @@ #include "mbed.h" #include "LSM9DS1.h" +#include "Wireless.h" //#include "USBKeyboard.h" #define PI 3.14159 // Earth's magnetic field varies by location. Add or subtract @@ -13,8 +14,9 @@ DigitalOut led3(LED3); DigitalOut led4(LED4); Serial pc(USBTX, USBRX); -DigitalIn pb1(p21); +DigitalIn pb1(p17); Timeout walkingTimer; +WirelessModule wireless(p9, p10, FOOT_STEP); bool isWalking = false; // Calculate pitch, roll, and heading. // Pitch/roll calculations taken from this app note: @@ -27,6 +29,7 @@ void printStop() { // pc.printf("stop\n\r"); + wireless.sendDirection(DIR_NONE); isWalking = false; } @@ -72,7 +75,7 @@ int main() { //LSM9DS1 lol(p9, p10, 0x6B, 0x1E); - LSM9DS1 IMU(p9, p10, 0xD6, 0x3C); + LSM9DS1 IMU(p28, p27, 0xD6, 0x3C); pb1.mode(PullUp); IMU.begin(); float forward; @@ -126,20 +129,20 @@ //Detect direction and send command to main mbed if((currHeading > 270 && currHeading < 360) && !isWalking) { - pc.printf("walking L\n\r"); + wireless.sendDirection(DIR_LEFT); isWalking = true; } else if((currHeading > 90 && currHeading < 180) && !isWalking) { - pc.printf("walking R\n\r"); + wireless.sendDirection(DIR_RIGHT); isWalking = true; } else if((currHeading > 180 && currHeading < 270) && !isWalking) { - pc.printf("walking D\n\r"); + wireless.sendDirection(DIR_DOWN); isWalking = true; } else if((currHeading > 360 || currHeading < 90) && !isWalking) { - pc.printf("walking F\n\r"); + wireless.sendDirection(DIR_UP); isWalking = true; } }