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: mbed line-trace2
Diff: main.cpp
- Revision:
- 1:a8fad3c66162
- Parent:
- 0:764148148257
- Child:
- 2:deefc81cf5a5
--- a/main.cpp Sat Dec 01 16:10:49 2018 +0000 +++ b/main.cpp Fri Dec 07 09:34:18 2018 +0000 @@ -1,4 +1,4 @@ -#include "count.h" +#include "function.h" PwmOut pwm11(D5); //左正転 PwmOut pwm12(D1); //左逆転 @@ -29,14 +29,14 @@ while(1) { - if( count1 + count2 > 43*2*12){ //LEDを点滅 + if( count1 + count2 > 43*2*12){ //200mm毎にLEDを点滅 LED = 1.0f; wait(0.5f); LED = 0; count1 = 0; count2 = 0; } -//////////////////float inをint judgeに変換 +//////////////////floatのinをintのjudgeに変換 if(in1 > thr1){ judge1 = 1; } @@ -57,38 +57,39 @@ } ///////////////// n = judge1 + judge2*2 + judge3*4; - - switch(n){ - - case(2)://白黒白進む - pwm11.write(0.60f); + /* distance = (distance1 + distance2) / 2; + if(ditance < 43*12*){ + */ + switch(n){ + case(2)://白黒白進む + pwm11.write(0.30f); pwm12.write(0.00f); - pwm21.write(0.60f); + pwm21.write(0.30f); pwm22.write(0.00f); break; - - case(0)://白白白 + + case(0)://白白白 pwm11.write(0.10f); pwm12.write(0.10f); pwm21.write(0.10f); pwm22.write(0.10f); break; - case(1)://黒白白左回転 + case(1)://黒白白左回転 pwm11.write(0.20f); pwm12.write(0.00f); - pwm21.write(0.00f); + pwm21.write(0.05f); pwm22.write(0.00f); break; - case(4)://白白黒右回転 - pwm11.write(0.00f); + case(4)://白白黒右回転 + pwm11.write(0.05f); pwm12.write(0.00f); pwm21.write(0.20f); pwm22.write(0.00f); break; - default://それ以外 + default://それ以外 pwm11.write(0.00f); pwm12.write(0.00f); pwm21.write(0.00f);