Manual
VISampleCodeforDFRobotShopRover
//*************************************************************************************************************************** 
// DFRobotShop Rover Line Sensor Arduino Sample Code 
// 
// Author : BD 
// Creation date: September 1, 2015 
// Subject: This Arduino Code intended to use the DFRobotShop Rover Line Sensor with the DFRbotoShop 
// Rover to follow a black line on a white background 
//*************************************************************************************************************************** 
int rsensor = 2; // Left Sensor on Analog Pin 2 
int lsensor = 1; // Right Sensor on Analog Pin 1 
int msensor = 0; // Middle Sensor on Analog Pin 0 
int E1 = 6; //M1 Speed Control 
int E2 = 5; //M2 Speed Control 
int M1 = 8; //M1 Direction Control 
int M2 = 7; //M2 Direction Control 
const int whitelevl = 600; // reading level is white if <600 
const int blacklevl = 850; // reading level is black if >850 
void setup() { 
 Serial.begin(9600); 
} 
void loop() { 
 // Case 1: Left sensor and right sensors are reading white and middle sensor is reading black. Drive forward! 
 if (readQD(lsensor) < whitelevl && readQD(msensor)> blacklevl && readQD(rsensor) < whitelevl) 
 { 
 goforward(); 
 } 
 // Case 2 : Left sensor and middle sensor are reading white and right sensor is reading black. Turn right! 
 else if (readQD(lsensor) < whitelevl && readQD(msensor)< whitelevl && readQD(rsensor) > blacklevl) 
 { 
 while(true) 
 { 
 turnright(); 
 if ((readQD(lsensor) < whitelevl && readQD(msensor)> blacklevl && readQD(rsensor) < whitelevl) || 
(readQD(lsensor)> blacklevl && readQD(msensor)> blacklevl && readQD(rsensor) < whitelevl)) 
{break;} // Break if Left sensor and right sensor are reading white and middle sensor is reading black 
 } 
 } 
 // Case 3 : Left sensor is reading white, middle sensor and right sensor are reading black. Turn right! 
 else if (readQD(lsensor) < whitelevl && readQD(msensor)> blacklevl && readQD(rsensor) > blacklevl) 
4










