歩行ロボ

Dependencies:   HMC6352 QEI Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
OGA
Date:
Thu Aug 01 09:05:23 2013 +0000
Parent:
0:4644bf6bca6a
Commit message:
????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 4644bf6bca6a -r f465d89a26b0 main.cpp
--- a/main.cpp	Wed Jul 31 04:43:58 2013 +0000
+++ b/main.cpp	Thu Aug 01 09:05:23 2013 +0000
@@ -8,7 +8,7 @@
 //#define ROTATE_PER_REVOLUTIONS  360//enko-da no bunkainou
 
 //QEI wheel(p23/*A*/, p24/*B*/, NC, ROTATE_PER_REVOLUTIONS, QEI::X4_ENCODING);
-//HMC6352 compass(p28/*sda*/, p27/*scl*/);
+HMC6352 compass(p28/*sda*/, p27/*scl*/);
 Servo myservo1(p21);
 Servo myservo2(p22);
 DigitalOut myled(LED1);
@@ -73,15 +73,16 @@
     
     timer2.start();
     interrupt.attach(&tic_sensor, 0.1/*sec*/);
-    //compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);
+    compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);
     //printf("test%d\n",com_val);
     
     while(1) {
     wait(0.1);
         
         
-        printf("pid:%.5d\n", ultrasonicVal[0]);
-        
+      //  printf("pid:%.5d\n", ultrasonicVal[0]);
+        printf("Heading is: %f\n", compass.sample() / 10.0);
+
         if((ultrasonicVal[0] < 1000)&&(ultrasonicVal[1] < 1000)){
             myservo1 = 0.5;
             myservo2 = 0.5;