Possible to make a line following robot with DC motors instead of servo motors?

Hello everyone,

I’m working on a robot, which is mainly supposed to follow a line.
So far so good, I found a good tutorial and built a working Infrared sensor. The problem I encounter now is, that the robot of the tutorial runs with servo motors, whereas I intended to use two 3-6V DC-motors with a gearbox. I did not expect that servo motors behave so differently than DC-motors.
I have: an Arduino Uno, a selfmade infrared sensor (as in the picture) and a L9110S motor controller, two 3-6V DC motors with gearbox.

My question to you would be: Is it doable to use the DC motors instead or should I really better use servo motors?

There are two codes I’m orienting at right now.
This one is the code for the line follower with the servo motors:

/*
Easy Line Follower Robot -DIYhacking.com Arvind Sanjeev

Quick and easy line following robot using an IR reflectance
array.Connect Vcc and Gnd to the Pololu QTR-8A sensor from 
the arduino. Connect the pins 1,2,3,... to arduino's analog
pins 0,1,2,3,4,5.
If the average of the 3 values of the sensors on the left is
greater than the average of those on the right, then the robot
moves left and vice versa.
NOTE : The values in the code for analog voltages would have 
to be modified if you are not using the Pololu QTR-8A reflectance
array sensor. Use trial and error to find out max and min 
values for your own IR array sensor.
 
 */
#include <Servo.h> 

Servo left;
Servo right; 

int mid = 0;
int mn = 0;
int mx = 0;

void setup()
{

left.attach(9, 800, 2200); //left servo motor
right.attach(10, 800, 2200); //right servo motor

Serial.begin(115200);

digitalWrite(13, LOW);

right.write(90);//stop signal
left.write(90);//stop signal

for(int i=0; i<5000; i++)
{
digitalWrite(13, HIGH);

int val = 0;
for(int j=0; j<=5; j++)//Calibrating the sensor, finding max and 
{                      //min reflectance values.
val = analogRead(j);
if(val >= mx)
mx = val;
if(val <= mn)
mn = val;
}
delay(1);
}

mid = ((mx + mn)/2);
digitalWrite(13, LOW);

right.write(90);
left.write(90);
}

void loop()
{

int s0 = 0;
int s1 = 0;
int s2 = 0;
int s3 = 0;
int s4 = 0;
int s5 = 0;

s0 = analogRead(0);//Signal pin 1 on the board
s1 = analogRead(1);//Signal pin 2 on the board
s2 = analogRead(2);//Signal pin 3 on the board
s3 = analogRead(3);//Signal pin 4 on the board
s4 = analogRead(4);//Signal pin 5 on the board
s5 = analogRead(5);//Signal pin 6 on the board

Serial.print("Mid: ");
Serial.print(mid); 
Serial.print(" ");
Serial.print(s0); 
Serial.print(" ");
Serial.print(s1); 
Serial.print(" ");
Serial.print(s2); 
Serial.print(" ");
Serial.print(s3); 
Serial.print(" ");
Serial.print(s4); 
Serial.print(" ");
Serial.print(s5); 
Serial.print(" ");
Serial.println();

right.write(180);//Move forward
left.write(0);//Move forward

delay(1);

if((((s0+s1+s2)/3)>(((s3+s4+s5)/3)+240)))//Move right
{
right.write(130);//180
left.write(90);//90
Serial.print(" RIGHT");
delay(abs((((s5+s4+s3)/3)-((s0+s1+s2)/3))/2));
}

if((((s0+s1+s2)/3)<(((s3+s4+s5)/3)-240)))//Move left
{
right.write(40);//90
left.write(0);//0
Serial.print(" LEFT");
delay(abs((((s5+s4+s3)/3)-((s0+s1+s2)/3))/2));
}

if((s0 > mid)&&(s5 > mid))//Stop if all the sensors give low 
{                         //reflectance values
right.write(90);
left.write(90);
Serial.print(" STOP");

for(int k=0; k<50; k++)
{
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}
delay(5000);
}


}

And here is a code I found to control a DC-motor with the motor shield:

I also found something about how to control the motors with an L293D chip, but I’m afraid my coding skills are not enough to change it on my own.

Thanks in advance for any help!

Hi, First you need to look for information and hopefully a library for your

a L9110S motor controller

Get your motors working first..

DC motors have often been used on line following robots. Because the line sensor information is constantly adjusting the motors, they don't have to be perfectly equal.