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.
Diff: main.cpp
- Revision:
- 7:e00a84257aa2
- Parent:
- 6:5c1ffbe1635b
- Child:
- 8:6320ca55f5d8
diff -r 5c1ffbe1635b -r e00a84257aa2 main.cpp
--- a/main.cpp Mon Jul 27 00:33:02 2020 +0000
+++ b/main.cpp Mon Jul 27 00:50:37 2020 +0000
@@ -31,7 +31,7 @@
const int limit = 20; // 障害物の距離のリミット(単位:cm)
int DT; // 距離
int houkou; // 進行方向(1:前 2:左 3:右)
-int max; // 最も遠い距離
+int far; // 最も遠い距離
int i; // ループ変数
/* 超音波センサ関数 */
@@ -126,23 +126,23 @@
run = STOP; // 停止
}
else { // 全方向以外
- max = SC; // 正面を最も遠い距離に設定
+ far = SC; // 正面を最も遠い距離に設定
houkou = 1; // 進行方向を前に設定
- if(max < SLD || max < SL){ // 左または左前がより遠い場合
+ if(far < SLD || far < SL){ // 左または左前がより遠い場合
if(SL < SLD){ // 左前が左より遠い場合
- max = SLD; // 左前を最も遠い距離に設定
+ far = SLD; // 左前を最も遠い距離に設定
}
else{ // 左が左前より遠い場合
- max = SL; // 左を最も遠い距離に設定
+ far = SL; // 左を最も遠い距離に設定
}
houkou = 2; // 進行方向を左に設定
}
- if(max < SRD || max < SR){ // 右または右前がより遠い場合
+ if(far < SRD || far < SR){ // 右または右前がより遠い場合
if(SR < SRD){ // 右前が右より遠い場合
- max = SRD; // 右前を最も遠い距離に設定
+ far = SRD; // 右前を最も遠い距離に設定
}
else{ // 右が右前よりも遠い場合
- max = SR; // 右を最も遠い距離に設定
+ far = SR; // 右を最も遠い距離に設定
}
houkou = 3; // 進行方向を右に設定
}
@@ -154,7 +154,7 @@
case 2: // 左の場合
run = LEFT; // 左折
while(i < 100){ // 進行方向確認
- if(watch() > (max - 2)){
+ if(watch() > (far - 2)){
i++;
}
else{
@@ -166,7 +166,7 @@
case 3: // 右の場合
run = RIGHT; // 右折
while(i < 100){ // 進行方向確認
- if(watch() > (max - 2)){
+ if(watch() > (far - 2)){
i++;
}
else{