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: RemoteIR TextLCD
Diff: main.cpp
- Revision:
- 19:c6f9f010bd9e
- Parent:
- 18:6cca64c7dbc3
- Child:
- 20:02bb875a9b13
--- a/main.cpp Wed Aug 05 01:09:50 2020 +0000
+++ b/main.cpp Wed Aug 05 02:07:18 2020 +0000
@@ -419,7 +419,7 @@
trig = 0;
ThisThread::sleep_for(5); // 5ms待つ
trig = 1;
- ThisThread::sleep_for(5); // 15ms待つ
+ ThisThread::sleep_for(15); // 15ms待つ
trig = 0;
timer.start();
t1=timer.read_ms();
@@ -459,13 +459,10 @@
//pc.printf("watchsurrounding\r\n");
SC = watch();
if(SC < limit){ // 正面20cm以内に障害物がある場合
- if(mode == AVOIDANCE) // 現在障害物回避モードなら
- run = STOP; // 停止
- else
- return;
+ run = STOP; // 停止
}
servo.pulsewidth_us(1925); // サーボを左に40度回転
- ThisThread::sleep_for(140); // 250ms待つ
+ ThisThread::sleep_for(180); // 250ms待つ
SLD = watch();
if(SLD < limit){ // 左前20cm以内に障害物がある場合
//if(mode == AVOIDANCE) // 現在障害物回避モードなら
@@ -474,7 +471,7 @@
//return;
}
servo.pulsewidth_us(2400); // サーボを左に90度回転
- ThisThread::sleep_for(100); // 250ms待つ
+ ThisThread::sleep_for(120); // 250ms待つ
SL = watch();
if(SL < limit){ // 左20cm以内に障害物がある場合
//if(mode == AVOIDANCE) // 現在障害物回避モードなら
@@ -482,8 +479,14 @@
//else
//return;
}
+ servo.pulsewidth_us(1450);
+ ThisThread::sleep_for(120);
+ SC = watch();
+ if(SC < limit){
+ run = STOP;
+ }
servo.pulsewidth_us(925); // サーボを右に40度回転
- ThisThread::sleep_for(140); // 250ms待つ
+ ThisThread::sleep_for(180); // 250ms待つ
SRD = watch();
if(SRD < limit){ // 右前20cm以内に障害物がある場合
//if(mode == AVOIDANCE) // 現在障害物回避モードなら
@@ -492,7 +495,7 @@
//return;
}
servo.pulsewidth_us(500); // サーボを右に90度回転
- ThisThread::sleep_for(100); // 250ms待つ
+ ThisThread::sleep_for(120); // 250ms待つ
SR = watch();
if(SR < limit){ // 右20cm以内に障害物がある場合
//if(mode == AVOIDANCE) // 現在障害物回避モードなら
@@ -501,7 +504,7 @@
//return;
}
servo.pulsewidth_us(1450); // サーボを中央位置に戻す
- ThisThread::sleep_for(100); // 100ms待つ
+ ThisThread::sleep_for(120); // 100ms待つ
if(SC < limit || SLD < limit || SL < limit || SRD < limit || SR < limit){ // 20cm以内に障害物を検知した場合
flag_a = 1; // 障害物有無フラグに1をセット
}