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.
Diff: main.cpp
- Revision:
- 32:b7a08eb0408d
- Parent:
- 31:19bb96d3113e
--- a/main.cpp Fri Jan 03 16:36:19 2020 +0000 +++ b/main.cpp Mon Jan 06 11:55:52 2020 +0000 @@ -173,60 +173,56 @@ while (SW1 == RELEASED); //Wait - so buggy doesn't move immediately wait(1.0); - //Main loop - while(1) { - straight(); //starts the straight function - oneRPS(); //starts oneRPS function - timeA(); //TimeA function to get wheel speed and distance - timeB(); //TimeB function to get wheel speed and distance + straight(); //starts the straight function + oneRPS(); //starts oneRPS function + timeA(); //TimeA function to get wheel speed and distance + timeB(); //TimeB function to get wheel speed and distance + terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); + while(travA <= 1250) { //starts moving from 0mm to 1250mm (distance of wheel travel) + timeA(); //Starts time A + timeB(); //starts time B + oneRPS(); //starts oneRPS function + terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); + } + reset(); //activates reset function + turn(); //starts turn function + while(travA <= 597) { //moves from 0mm to 597mm (distance of outside wheel travel) + timeA(); //starts time A + timeB(); //starts time B + cornerRPS(); //starts CornerRPS function terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); - while(travA <= 1250) { //starts moving from 0mm to 1250mm (distance of wheel travel) - timeA(); //Starts time A - timeB(); //starts time B - oneRPS(); //starts oneRPS function - terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); - } - reset(); //activates reset function - turn(); //starts turn function - while(travA <= 597) { //moves from 0mm to 597mm (distance of outside wheel travel) - timeA(); //starts time A - timeB(); //starts time B - cornerRPS(); //starts CornerRPS function - terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); - } - reset(); //activates reset function - straight(); //starts the straight function - while(travA <= 1457) { //starts moving from 0mm to 1457mm (distance of wheel travel) - timeB(); //starts time A - timeA(); //starts time B - oneRPS(); //starts oneRPS function - terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); - } - reset(); //activates reset function - turn(); //starts turn function - while(travA <= 453.8) { //starts moving from 0mm to 453.8mm (distance of wheel travel) - timeA(); //starts time A - timeB(); //starts time B - cornerRPS(); ///starts CornerRPS function - terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); - } - reset(); //activates reset function - straight(); //starts the straight function - while(travA <= 750) { //starts moving from 0mm to 750mm (distance of wheel travel) - timeB(); //starts time A - timeA(); //starts time B - oneRPS(); //starts oneRPS function - terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); - } - reset(); //activates reset function - turn(); //starts turn function - while(travA <= 350.3) { //starts moving from 0mm to 349mm (distance of wheel travel) - timeA(); //starts time A - timeB(); //starts time B - cornerRPS(); //starts CornerRPS function - terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); - } - break; + } + reset(); //activates reset function + straight(); //starts the straight function + while(travA <= 1457) { //starts moving from 0mm to 1457mm (distance of wheel travel) + timeB(); //starts time A + timeA(); //starts time B + oneRPS(); //starts oneRPS function + terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); + } + reset(); //activates reset function + turn(); //starts turn function + while(travA <= 453.8) { //starts moving from 0mm to 453.8mm (distance of wheel travel) + timeA(); //starts time A + timeB(); //starts time B + cornerRPS(); ///starts CornerRPS function + terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); + } + reset(); //activates reset function + straight(); //starts the straight function + while(travA <= 750) { //starts moving from 0mm to 750mm (distance of wheel travel) + timeB(); //starts time A + timeA(); //starts time B + oneRPS(); //starts oneRPS function + terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); + } + reset(); //activates reset function + turn(); //starts turn function + while(travA <= 350.3) { //starts moving from 0mm to 349mm (distance of wheel travel) + timeA(); //starts time A + timeB(); //starts time B + cornerRPS(); //starts CornerRPS function + terminal.printf("wheelA: %6.3f \t wheelB: %6.3f \t distanceA: %6.2f \t distanceB: %6.2f\n\r", speedA, speedB, travA, travB); } PWMA.write(0.0f); //tells wheel A to stop PWMB.write(0.0f); //tells wheel B to stop