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:
- 16:25eb20a73e59
- Parent:
- 15:60d699b587c5
- Child:
- 17:b5886b554381
diff -r 60d699b587c5 -r 25eb20a73e59 main.cpp --- a/main.cpp Thu Mar 26 20:23:16 2015 +0000 +++ b/main.cpp Thu Mar 26 21:26:54 2015 +0000 @@ -88,7 +88,7 @@ int num_of_right=0; //servo is offset zero by some bullshit number - float bullshit_offset = .074; + float bullshit_offset = .068; // major loop while(1) { @@ -181,9 +181,9 @@ if(center_now > 10 && center_now < 45) // linear func num = 1; - else if(center_now >= 45 && center_now < 63) // snap + else if(center_now >= 45 && center_now < 65) // snap num = 2; - else if(center_now > 63 && center_now < 65) // nothing zone + else if(center_now > 64 && center_now < 64) // nothing zone num = 15; else if(center_now >= 65 && center_now < 83) // snap num = 4; @@ -212,7 +212,8 @@ if (left_counter >-.45) //left_counter -=.05; //left_counter -=.03; - left_counter -= (.001428571*center_now); + //left_counter -= (.001428571*(128-center_now)); + left_counter -= (.0015*(128-center_now)); turn_left=true; turn_right=false; @@ -248,7 +249,8 @@ if (right_counter <.45) //right_counter +=.05; //right_counter +=.03; - right_counter +=(.001428571*center_now); + //right_counter +=(.001428571*center_now); + right_counter +=(.0015*center_now); turn_left=false; turn_right=true; @@ -278,7 +280,8 @@ num_of_right = 0; num_of_left++; turn_right = false; - TFC_SetServo(0,left_counter + bullshit_offset ); // set turning servo + if (left_counter + bullshit_offset > -.35) + TFC_SetServo(0,left_counter + bullshit_offset ); // set turning servo // normalize to center each frame // left turning is - servo @@ -297,7 +300,7 @@ need_decel = false; } else // turning speeds - TFC_SetMotorPWM(current_left_motor_speed+(.3*left_counter), current_right_motor_speed+(.3*left_counter)+(.00005*num_of_left)); // ++left is slowed, ++right is faster + TFC_SetMotorPWM(current_left_motor_speed+(.25*left_counter), current_right_motor_speed+(.3*left_counter)+(.0005*num_of_left)); // ++left is slowed, ++right is faster }// end of turn left // set servo and motors according to how much right we need to turn @@ -308,7 +311,9 @@ num_of_left=0; turn_left =false; - TFC_SetServo(0,right_counter - bullshit_offset); // set servo + + if (right_counter - bullshit_offset < .5) + TFC_SetServo(0,right_counter - bullshit_offset); // set servo // normalize to center each frame // right turning is + servo @@ -328,7 +333,7 @@ need_decel = false; } else // turning speeds - TFC_SetMotorPWM(current_left_motor_speed-(.3*right_counter)-(.00005*num_of_right), current_right_motor_speed-(.3*right_counter)); // --left is faster, --right is slowed + TFC_SetMotorPWM(current_left_motor_speed-(.3*right_counter)-(.0005*num_of_right), current_right_motor_speed-(.25*right_counter)); // --left is faster, --right is slowed } // end with turn right