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: BMX055 Motor Way
Diff: main.cpp
- Revision:
- 2:09ea66e396c1
- Parent:
- 1:bb85c9fe1ba3
- Child:
- 3:efc081576a33
diff -r bb85c9fe1ba3 -r 09ea66e396c1 main.cpp --- a/main.cpp Thu Nov 28 07:21:36 2019 +0000 +++ b/main.cpp Wed Dec 04 02:32:00 2019 +0000 @@ -20,6 +20,7 @@ const float INTVAL_MOTOR (0.25); float dist = 0.0; +float standard_rpm = 0; void count_pg1() { @@ -33,10 +34,10 @@ void line_trace() { - const float fast_rpm = 1500; - const float standard_rpm = 1200; - const float slow_rpm = 750; - const float K = 850; + //const float fast_rpm = 2000; + //const float standard_rpm = 1200; + //const float slow_rpm = 1000; + const float K = 750;//850; const int L = 0; const int R = 1; @@ -47,22 +48,22 @@ while(1) { - if( reflectorF<=0.4 && reflectorR<=0.4 && reflectorL<= 0.4 ) + if( /*reflectorF<=0.4 &&*/ reflectorR<=0.4 && reflectorL<= 0.4 ) { if( flag == L ) { - motorL.Set_phase(1); - motorL.Set_target(slow_rpm); + motorL.Set_phase(0);//1); + motorL.Set_target(0);//slow_rpm); motorR.Set_phase(1); - motorR.Set_target(slow_rpm); + motorR.Set_target(standard_rpm);//slow_rpm); //printf("turnL\n"); } else { motorL.Set_phase(0); - motorL.Set_target(slow_rpm); - motorR.Set_phase(0); - motorR.Set_target(slow_rpm); + motorL.Set_target(standard_rpm);//slow_rpm); + motorR.Set_phase(1);//0); + motorR.Set_target(0);//slow_rpm); //printf("turnR\n"); } } @@ -120,6 +121,11 @@ dist_count += ( v + v_pre ) * INTVAL_MOTOR/2; v_pre = v; + if (dist<=2000) standard_rpm = 2000; + else if(dist<=2400) standard_rpm = 1200; + else if(dist<=4400) standard_rpm = 2000; + else standard_rpm = 1000; + printf("%f\n", dist); if( dist_count >= 200 )