Basic motor code

Dependencies:   Motordriver mbed HALLFX_ENCODER Servo

Revision:
4:a21d15629407
Parent:
3:c4b0460d8886
Child:
5:7572f73a78f3
--- 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