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 MODSERIAL telemetry-master
Fork of coolcarsuperfast by
Diff: main.cpp
- Revision:
- 17:28a1f9309fdb
- Parent:
- 16:79106efd7a57
- Child:
- 18:7941524e0d28
--- a/main.cpp Sat Apr 11 00:33:05 2015 +0000 +++ b/main.cpp Wed Apr 22 22:55:24 2015 +0000 @@ -40,7 +40,7 @@ //Line Crossing variables int prevTrackLoc; int spaceThresh = 1; -int widthThresh = 10; +int widthThresh = 8; bool space; //Servo turning parameters @@ -86,7 +86,7 @@ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PWM & Integration Time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ float pulsewidth = 0.20f; -int intTimMod = 20; +int intTimMod = 0; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool turnSpeedControl = true; @@ -413,7 +413,7 @@ } for (int c = startWindow; c < endWindow; c++) { - if (ADCdata[c] <= maxVal && maxVal - ADCdata[c] < 0.01f){ + if (ADCdata[c] <= maxVal && maxVal - ADCdata[c] < 0.25f){ maxAccum += c; maxCount++; if (c > prevTrackLoc + spaceThresh || maxCount > widthThresh){ @@ -457,14 +457,14 @@ if (turnSpeedControl){ //Change speed when turning at different angles if(approxPos > 0 && approxPos <= 45){ - motor1.pulsewidth(motorPeriod*(pulsewidth*0.8f)); - motor2.pulsewidth(motorPeriod*(pulsewidth*0.8f)); + motor1.pulsewidth(motorPeriod*(pulsewidth*1.2f)); + motor2.pulsewidth(motorPeriod*(pulsewidth*1.2f)); } else if (approxPos > 45 && approxPos <= 95){ motor1.pulsewidth(motorPeriod*pulsewidth); motor2.pulsewidth(motorPeriod*pulsewidth); } else { - motor1.pulsewidth(motorPeriod*(pulsewidth*0.8f)); - motor2.pulsewidth(motorPeriod*(pulsewidth*0.8f)); + motor1.pulsewidth(motorPeriod*(pulsewidth*1.2f)); + motor2.pulsewidth(motorPeriod*(pulsewidth*1.2f)); } }