|
@@ -65,8 +65,8 @@ void loop() {
|
|
|
//Read and scale analog inputs
|
|
|
maxSpeed = map (analogRead(maxSpeed_pin), 0, 1024, 0, 255);
|
|
|
driftCorrection = analogRead(driftCorrection_pin) ;
|
|
|
- driftCorrection -= 512;
|
|
|
- driftCorrection /= 8 ;
|
|
|
+ driftCorrection = driftCorrection / 512 - 1 ; // -1..1
|
|
|
+ driftCorrection *= 0.5 ;
|
|
|
|
|
|
Serial.print("maxSpeed:"); //Serial debugging stuff
|
|
|
Serial.println(maxSpeed);
|
|
@@ -102,8 +102,8 @@ void loop() {
|
|
|
if (turn>0) { speeds[0] = move; speeds[1] = move - turn ; }
|
|
|
if (turn<=0) { speeds[0] = move + turn ; speeds[1] = move ; }
|
|
|
|
|
|
-// if (driftCorrection>0) { speeds[0] -= driftCorrection*; speeds[1] = move - turn ; }
|
|
|
-// if (driftCorrection<=0) { speeds[0] = move + turn ; speeds[1] = move ; }
|
|
|
+ if (driftCorrection>0) { speeds[0] *= 1-driftCorrection ; }
|
|
|
+ if (driftCorrection<=0) { speeds[1] *= 1+driftCorrection ; }
|
|
|
//
|
|
|
Serial.print("speeds: "); //Serial debugging stuff
|
|
|
Serial.print(speeds[0]);
|