Moving Line Follower During Calibration

Hey Guys,

I have made a line follower and have gotten it to work reasonably well, however, during calibration I have to manually move the robot and the accompanying sensor array (QTR-8RC) over the line. I would like to create a code where I can simply place the robot on the line and it will spin the wheels in a way so that it will basically oscillate over the line a couple times during this calibration phase. At the moment I have had no luck and have tried searching around but with no luck. Im using 50:1 HP micrometal motors, with an UNO R3 and motor shield. I have pasted the part of the code which concerns my problem. Basically I need to throttle the motors forward and reverse whilst the array calibrates. Thanks for your time and hop my question makes sense!!!

#include <QTRSensors.h>

#define Kp 6 // experiment to determine this, start by something small that just makes your bot follow the line at a slow speed
#define Kd 70 // experiment to determine this, slowly increase the speeds and adjust this value. ( Note: Kp < Kd) 
#define RIGHT_MAX_SPEED 90 // max speed of the robot
#define LEFT_MAX_SPEED 90 // max speed of the robot
#define RIGHT_BASE_SPEED 80 // this is the speed at which the motors should spin when the robot is perfectly on the line
#define LEFT_BASE_SPEED 80  // this is the speed at which the motors should spin when the robot is perfectly on the line
#define NUM_SENSORS  8      // number of sensors used
#define TIMEOUT       2500  // waits for 2500 us for sensor outputs to go low
#define EMITTER_PIN   QTR_NO_EMITTER_PIN     // emitter is controlled by digital pin 2

#define rightMotor1 12 
#define rightMotorPWM 10
#define leftMotor1 13
#define leftMotorPWM 11

QTRSensorsRC qtrrc((unsigned char[]) {2, 3, 4, 5, 6, 7, 8, 9} ,NUM_SENSORS, TIMEOUT, EMITTER_PIN); // sensor connected through analog pins A0 - A5 i.e. digital pins 14-19

unsigned int sensorValues[NUM_SENSORS];

void setup()
{
  pinMode(rightMotor1, OUTPUT);
  pinMode(rightMotorPWM, OUTPUT);
  pinMode(leftMotor1, OUTPUT);
  pinMode(leftMotorPWM, OUTPUT);
  
  int i;
for (int i = 0; i < 100; i++) // calibrate for sometime by sliding the sensors across the line, or you may use auto-calibration instead

  // Automatic Calibration Below That I Need Help With!!!
  if ( i  <= 25 || i >= 75 )
   { 
    digitalWrite(leftMotor1, LOW);   
   }
     else
   {  
    digitalWrite(rightMotor1, HIGH);   
   }*/

   qtrrc.calibrate();   
   delay(20);
 
 delay(2000); // wait for 2s to position the bot before entering the main loop

I have pasted the part of the code which concerns my problem

You need to post ALL of your code. That code with stuff randomly placed makes no sense.

  int i;
for (int i = 0; i < 100; i++)

During the body of the for loop, which doesn’t have curly braces, you have two variables named i. Why?