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:
- 5:237c49800e14
- Parent:
- 4:45b45e8ca173
- Child:
- 6:9bd1da494e0b
--- a/main.cpp Mon Dec 17 05:55:01 2018 +0000
+++ b/main.cpp Mon Dec 17 12:02:19 2018 +0000
@@ -16,9 +16,9 @@
float gain2 = 0.0f;//右ゲイン
float dif1 = 0.0f;//目標との差左
float dif2 = 0.0f;//目標との差右
-float thr1 = 0.70f;//フォトリフレクタのしきい値左
-float thr2 = 0.70f;//フォトリフレクタのしきい値真ん中
-float thr3 = 0.70f;//フォトリフレクタのしきい値右
+float thr1 = 0.40f;//フォトリフレクタのしきい値左
+float thr2 = 0.40f;//フォトリフレクタのしきい値真ん中
+float thr3 = 0.40f;//フォトリフレクタのしきい値右
int judge1 = 0;
int judge2 = 0;
int judge3 = 0;
@@ -42,7 +42,7 @@
distance = (distance1+distance2)/2;
if(distance < 43*2*12*mode1){
-
+ /*
if( led_count1 + led_count2 > 43*2*12){ //200mm毎にLEDを点滅
LED = 1.0f;
wait(0.5f);
@@ -50,6 +50,7 @@
led_count1 = 0;
led_count2 = 0;
}
+ */
//////////////////floatのinをintのjudgeに変換
if(in1 > thr1){
judge1 = 1;
@@ -75,60 +76,60 @@
switch(n){
case(2)://白黒白進む
g = 500.0f;
- gain1 = g - c2;
- gain2 = g - c1;
+ gain1 = g - c1;
+ gain2 = g - c2;
- pwm11.write(0.50f + gain1*0.00001f);
+ pwm11.write(0.40f);
pwm12.write(0.30f);
- pwm21.write(0.50f + gain2*0.00001f);
+ pwm21.write(0.40f);
pwm22.write(0.30f);
break;
case(0)://白白白
g = 600.0f;
- gain1 = g - c2;
- gain2 = g - c1;
+ gain1 = g - c1;
+ gain2 = g - c2;
- pwm11.write(0.10f);
- pwm12.write(0.40f );
- pwm21.write(0.10f);
- pwm22.write(0.40f );
+ pwm11.write(0.30f);
+ pwm12.write(0.40f);
+ pwm21.write(0.30f);
+ pwm22.write(0.40f);
break;
case(1)://黒白白左回転強
- pwm11.write(0.45f);
+ pwm11.write(0.30f);
pwm12.write(0.30f);
- pwm21.write(0.50f);
- pwm22.write(0.30f);
+ pwm21.write(0.30f);
+ pwm22.write(0.20f);
break;
case(4)://白白黒右回転
- pwm11.write(0.50f);
- pwm12.write(0.30f);
- pwm21.write(0.45f);
+ pwm11.write(0.30f);
+ pwm12.write(0.20f);
+ pwm21.write(0.30f);
pwm22.write(0.30f);
break;
case(3)://黒黒白左回転弱
- pwm11.write(0.45f);
+ pwm11.write(0.30f);
pwm12.write(0.30f);
- pwm21.write(0.46f);
- pwm22.write(0.30f);
+ pwm21.write(0.30f);
+ pwm22.write(0.20f);
break;
case(6)://白黒黒右回転弱
- pwm11.write(0.46f);
- pwm12.write(0.30f);
- pwm21.write(0.45f);
+ pwm11.write(0.30f);
+ pwm12.write(0.20f);
+ pwm21.write(0.30f);
pwm22.write(0.30f);
break;
case(7)://黒黒黒爆走
- pwm11.write(0.60f);
+ pwm11.write(0.40f);
pwm12.write(0.30f);
- pwm21.write(0.60f);
+ pwm21.write(0.40f);
pwm22.write(0.30f);
break;