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: ADXL345_I2C_NEST HMC6352 IMUfilter ITG3200_NEST USBHost mbed-rtos mbed
Fork of Project by
Revision 1:41cee26b35cc, committed 2014-04-11
- 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
--- /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) {
