Mine, not yours justin

Dependencies:   HMC6352 USBHost mbed-rtos mbed

Fork of Project by Justin Eng

Files at this revision

API Documentation at this revision

Comitter:
Strikewolf
Date:
Fri Apr 11 17:54:21 2014 +0000
Parent:
0:b6fd1c37944a
Child:
2:56eb726bdb0d
Commit message:
Additional work on functions

Changed in this revision

HMC6352.lib Show annotated file Show diff for this revision Revisions of this file
RobotControl.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HMC6352.lib	Fri Apr 11 17:54:21 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/aberk/code/HMC6352/#83c0cb554099
--- a/RobotControl.h	Fri Apr 11 17:40:07 2014 +0000
+++ b/RobotControl.h	Fri Apr 11 17:54:21 2014 +0000
@@ -5,7 +5,7 @@
 #include "HMC6352.h"
 
 //Gyro
-HMC6532 compass(p28, p27);
+HMC6352 compass(p28, p27);
 
 //H-bridge
 PwmOut rightMotorPWM(p21);  //Channel A
@@ -33,14 +33,26 @@
     rightMotorPWM = 0;
     leftMotorPWM = 0;
     leftMotor1 = 0;
-    leftMotor2 = 0;
-    rightMotor1 = 0;
+    leftMotor2 = 1;
+    rightMotor1 = 1;
     rightMotor2 = 0;
 }
 
-//Need compass module
+//These functions are not completed yet...
 void gyroDriveStraight(float speed, bool reverse);
-void centerTurnLeft(int delta_degrees);
+void centerTurnLeft(int delta_degrees) {
+    double initial = compass.sample() / 10;
+    while ((compass.sample() / 10) > initial - delta_degrees){
+        //Set speed
+        rightMotorPWM = 0.8;
+        leftMotorPWM = 0.8;
+        leftMotor1 = 1;
+        leftMotor2 = 0;
+        rightMotor1 = 1;
+        rightMotor1 = 0; 
+    }
+    stop();
+}
 void centerTurnRight(int delta_degrees);
 void driveTurnLeft(int delta_degrees);
 void driveTurnRight(int delta_degrees);
--- a/main.cpp	Fri Apr 11 17:40:07 2014 +0000
+++ b/main.cpp	Fri Apr 11 17:54:21 2014 +0000
@@ -2,10 +2,10 @@
 #include "RobotControl.h"
 
 int main() {
-    setDriveStraight(1, false);
-    wait(1);
-    setDriveStraight(1, true);
-    wait(1);
+    //Init compass
+    compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);
+    wait(2);
+    //centerTurnLeft(25);
     stop();
     
     while(1) {