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.
Dependencies: Motordriver mbed HALLFX_ENCODER Servo
Revision 4:a21d15629407, committed 2018-04-21
- Comitter:
- amohile3
- Date:
- Sat Apr 21 19:48:25 2018 +0000
- Parent:
- 3:c4b0460d8886
- Child:
- 5:7572f73a78f3
- Commit message:
- Added turnRight() and makeCircle() methods
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Apr 20 17:54:08 2018 +0000
+++ b/main.cpp Sat Apr 21 19:48:25 2018 +0000
@@ -45,6 +45,27 @@
wait(0.1);
}
+void turnRight(int degrees) {
+ leftEnc.reset();
+ rightEnc.reset();
+ right.speed(-SPEED);
+ left.speed(SPEED);
+ float numTicks = degrees * TicksPerDeg;
+ while (leftEnc.read() < numTicks && rightEnc.read() < numTicks) {}
+ stop();
+ wait(0.1);
+}
+
+void makeCircle() {
+ leftEnc.reset();
+ rightEnc.reset();
+ right.speed(SPEED);
+ float numTicks = 360 * TicksPerDeg;
+ while (rightEnc.read() < numticks) {}
+ stop();
+ wait(0.1);
+}
+
void manualCheck() {
leftEnc.reset();
rightEnc.reset();
@@ -58,9 +79,10 @@
int main() {
//forward(5.0);
//turnLeft(90);
- forward(5.0);
- turnLeft(45);
- forward(5.0);
+ for (int i = 0; i < 3; i++){
+ forward(5.0);
+ turnLeft(120);
+ }
//manualcheck();
//forward(10.0);
}
\ No newline at end of file