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: AQM0802A HMC6352 PID Servo mbed
Diff: main.cpp
- Revision:
- 2:de6958cb7072
- Parent:
- 1:438016436d16
--- a/main.cpp Sat Feb 14 06:33:25 2015 +0000
+++ b/main.cpp Sun Feb 22 07:36:26 2015 +0000
@@ -376,10 +376,10 @@
S555.calibrate(0.0005, 120.0);
S555.position(0.0); //初期位置にセット
- /*
+
hmc6352.setOpMode(HMC6352_CONTINUOUS, 1, 20);
*compass_def = (hmc6352.sample() / 10);
- */
+
//Lcd.cls();
}
@@ -450,6 +450,7 @@
/*Compass*/
int CompassDef = 0, Compass = 0;
+ hmc6352.setOpMode(HMC6352_CONTINUOUS, 1, 20);
/*State */
//Direction LineIr = NA;//方位設定奴...エラーでてめんどくさいので後でまたやることにする。
@@ -467,6 +468,7 @@
//StartLoop(); /*loop stat, switch push end*/
int val = 0;
+ int compassy;
char data[3] = {0};
char order[1] = {0};
while(1) {
@@ -509,21 +511,71 @@
//IrNum = IrReceive(IrData);
order[0] = 0x00;
+ for(int i=0; i<3; i++) data[i]=100;
val = Sensor.write(ADDRESS_R&0xFE, order , 1);
+ Led[0] = 0;
Led[1] = !val;
- wait_ms(1);
+ wait_ms(.25);
val = Sensor.read(ADDRESS_R|1, data, 3);// IRデータを受信
Led[0] = !val;
+ Led[1] = 0;
- wait_ms(1);
+ wait_ms(.25);
pc.printf("num = %d irData1 = %d irData2 = %d\n",(int)data[0],(int)data[1],(int)data[2]);
+ for(int i=0; i<3; i++) data[i]=100;
+
+
+
+
+
+
+
+
+ val = Sensor.write((ADDRESS_R+2)&0xFE, order , 1);
+
+ Led[0] = 0;
+ Led[1] = !val;
+
+ wait_ms(.25);
+
+ val = Sensor.read((ADDRESS_R+2)|1, data, 3);// IRデータを受信
+
+ Led[0] = !val;
+ Led[1] = 0;
+
+ wait_ms(.25);
+
+ pc.printf("num = %d irData1 = %d irData2 = %d\n",(int)data[0],(int)data[1],(int)data[2]);
+
+ for(int i=0; i<3; i++) data[i]=100;
+
+
+
+
+
+ //pc.printf("Heading is: %03d\n",(int)((hmc6352.sample()/10.0)+0.5));
+
+ compassy = (
+ (
+ ((int)(hmc6352.sample()/10.0))
+ + 540
+ - CompassDef
+ )%360
+ );
+
+ Lcd.cls();
+ Lcd.printf("Hello\n %d", compassy );
+
+ wait_ms(.25);
+
+ for(int i=0; i<3; i++) data[i]=100;
/*複雑な処理が必要な箇所については関数に飛ばす*/