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:
- 2:5f29bc7daa49
- Parent:
- 1:4ab886b72870
- Child:
- 3:d3264a6f7a62
diff -r 4ab886b72870 -r 5f29bc7daa49 main.cpp --- a/main.cpp Fri Mar 16 20:50:41 2018 +0000 +++ b/main.cpp Sat Mar 24 18:04:21 2018 +0000 @@ -46,13 +46,14 @@ void grabToken();//Picks up the token for reading void dropToken();//Drops the token off void kill(); +void turnLeft(int, bool); //void rot90(); //Rotates the robot 90 degrees to the left //void rot180(); //Turns the robot around const int FORWARD = 0; const int BACKWARD = 1; const float stepSize = 0.001212; //in meters - const float FREQUENCY = 500; //dist per second + const float FREQUENCY = 500; //steps per second @@ -135,9 +136,20 @@ magArm.period(0); magArm.write(0); } -void rot90() -{ - +void turnLeft(int dist, bool direction) +{ + //Get rid of all FR occurences which will turn right motor off + FLdirection = direction; //to turn left we want this going FORWARD so a 0; + + + stepFL.period(1/FREQUENCY); + stepFL.write(0.5); + + //dist/stepSize is the number of steps + //1/FREQUENCY is the time per step + wait((dist/stepSize)*(1/FREQUENCY)); + stepFL.period(0); + stepFL.write(0); } void rot180() {