Michael Romain
/
coolcarsuperfast
Just trying to update ccode.
Fork of coolcarsuperfast by
Diff: main.cpp
- Revision:
- 4:09c68df71785
- Parent:
- 3:e867c4e984df
- Child:
- 5:20223464f7aa
--- a/main.cpp Fri Mar 20 10:49:25 2015 +0000 +++ b/main.cpp Sat Mar 21 01:40:29 2015 +0000 @@ -27,9 +27,9 @@ //Servo turning parameters float straight = 0.00155f; -float hardLeft = 0.0013f; +float hardLeft = 0.0012f; float slightLeft = 0.00145f; -float hardRight = 0.0018f; +float hardRight = 0.0020f; float slightRight = 0.00165f; //End of Line Tracking Variables ------------------------- @@ -227,8 +227,8 @@ wait(5); - motor1.pulsewidth(.0025*.105); - motor2.pulsewidth(.0025*.105); + motor1.pulsewidth(.0025*.11); + motor2.pulsewidth(.0025*.11); break1 = 0; break2 = 0; @@ -298,7 +298,7 @@ //approxPos = find_track(ADCdata); - if(approxPos > 0 && approxPos <= 25){ + /* if(approxPos > 0 && approxPos <= 25){ servo.pulsewidth(hardLeft); motor1.pulsewidth(.0025*.1); motor2.pulsewidth(.0025*.1); @@ -319,21 +319,41 @@ motor1.pulsewidth(.0025*.1); motor2.pulsewidth(.0025*.1); } - /* - if(approxPos > 0 && approxPos <= 45){ + */ + + /*if(approxPos > 0 && approxPos <= 45){ servo.pulsewidth(hardLeft); + motor1.pulsewidth(.0025*.095); + motor2.pulsewidth(.0025*.095); } else if (approxPos > 45 && approxPos <= 95){ servo.pulsewidth(straight); + motor1.pulsewidth(.0025*.11); + motor2.pulsewidth(.0025*.11); } else { servo.pulsewidth(hardRight); + motor1.pulsewidth(.0025*.095); + motor2.pulsewidth(.0025*.095); }*/ + + if(approxPos > 0 && approxPos <= 45){ + motor1.pulsewidth(.0025*.095); + motor2.pulsewidth(.0025*.095); + } else if (approxPos > 45 && approxPos <= 95){ + motor1.pulsewidth(.0025*.11); + motor2.pulsewidth(.0025*.11); + } else { + motor1.pulsewidth(.0025*.095); + motor2.pulsewidth(.0025*.095); + } + servo.pulsewidth(.0012 + approxPos/((float) 128)*.0008); + //velocity_control(0.05f, DESIRED_SPEED); integrationCounter = 150; } else{ clk = 1; - wait_us(220); + wait_us(80); ADCdata[integrationCounter - 1] = camData; clk = 0; }