
Wi-Fi追加
Dependencies: RemoteIR TextLCD
Revision 22:c6e2a3b9aa14, committed 2020-08-05
- Comitter:
- tomotsugu
- Date:
- Wed Aug 05 07:05:42 2020 +0000
- Parent:
- 21:68d38e8f64b5
- Child:
- 23:8c862b55fa1f
- Commit message:
- jhfzifg
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Aug 05 02:39:37 2020 +0000 +++ b/main.cpp Wed Aug 05 07:05:42 2020 +0000 @@ -58,7 +58,7 @@ int beforeMode; // 前回のモード int flag_sp = 0; // スピード変化フラグ Timer viewTimer; // スピ―ド変更時に3秒計測タイマー -float motorSpeed[9] = {0.5, 0.6, 0.7, 0.75, 0.85, 0.95, 0.8, 0.9, 1.0}; +float motorSpeed[9] = {0.5, 0.8, 0.9, 0.75, 0.85, 0.95, 0.8, 0.9, 1.0}; // モーター速度設定(後半はライントレース用) Mutex mutex; // ミューテックス @@ -421,7 +421,7 @@ timer.start(); t1=timer.read_ms(); t2=timer.read_ms(); - while(echo.read() == 0&&(t1-t2)<10){ + while(echo.read() == 0 &&(t1-t2)<10){ t1=timer.read_ms(); led1 = 1; } @@ -436,8 +436,8 @@ } timer.stop(); // 距離計測タイマーストップ DT = (int)(timer.read_us()*0.01657); // 距離計算 - if(DT > 100){ // 検知範囲外なら100cmに設定 - DT = 100; + if(DT > 150){ // 検知範囲外なら100cmに設定 + DT = 150; } timer.reset(); // 距離計測タイマーリセット led1 = 0; @@ -446,42 +446,44 @@ /* 障害物検知関数 */ void watchsurrounding(){ + servo.pulsewidth_us(1450); // サーボを中央位置に戻す + ThisThread::sleep_for(90); // 100ms待つ SC = watch(); if(SC < limit){ // 正面20cm以内に障害物がある場合 run = STOP; // 停止 } servo.pulsewidth_us(1925); // サーボを左に40度回転 - ThisThread::sleep_for(180); // 250ms待つ + ThisThread::sleep_for(200); // 250ms待つ SLD = watch(); if(SLD < limit){ // 左前20cm以内に障害物がある場合 run = STOP; // 停止 } servo.pulsewidth_us(2400); // サーボを左に90度回転 - ThisThread::sleep_for(120); // 250ms待つ + ThisThread::sleep_for(200); // 250ms待つ SL = watch(); if(SL < limit){ // 左20cm以内に障害物がある場合 run = STOP; // 停止 } servo.pulsewidth_us(1450); - ThisThread::sleep_for(120); + ThisThread::sleep_for(90); SC = watch(); if(SC < limit){ run = STOP; } servo.pulsewidth_us(925); // サーボを右に40度回転 - ThisThread::sleep_for(190); // 250ms待つ + ThisThread::sleep_for(200); // 250ms待つ SRD = watch(); if(SRD < limit){ // 右前20cm以内に障害物がある場合 run = STOP; // 停止 } servo.pulsewidth_us(500); // サーボを右に90度回転 - ThisThread::sleep_for(120); // 250ms待つ + ThisThread::sleep_for(200); // 250ms待つ SR = watch(); if(SR < limit){ // 右20cm以内に障害物がある場合 run = STOP; // 停止 } servo.pulsewidth_us(1450); // サーボを中央位置に戻す - ThisThread::sleep_for(120); // 100ms待つ + ThisThread::sleep_for(80); // 100ms待つ if(SC < limit || SLD < limit || SL < limit || SRD < limit || SR < limit){ // 20cm以内に障害物を検知した場合 flag_a = 1; // 障害物有無フラグに1をセット }