Line Follower Sensor V1.
Table of contents I Overview II Features III Specifications IV Dimensions V Schematic VI Sample Code for DFRobotShop Rover VII Installation On DFRobotShop Rover VIII Questions/Troubleshooting I Overview The DFRobotShop Rover Line Follower Sensor is intended as a standalone product or as an upgrade to any DFRobotShop Rover, allowing the robot to follow a black line on white background.
IV Dimensions 2
V Schematic 3
VI Sample Code for DFRobotShop Rover //*************************************************************************************************************************** // 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 //***********************************************************************************
{ 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 4 : Left sensor is reading black, middle sensor and right sensor are reading white.
digitalWrite(M2,HIGH); } //////////////////////////////////////////////////// ///////////// Turn Left Routine /////////////////// void turnleft(){ analogWrite (E1,210); digitalWrite(M1,HIGH); analogWrite (E2,210 ); digitalWrite(M2,LOW); } //////////////////////////////////////////////////// //////////////////// Read Sensor Routine ////////// int readQD(int x){ int val = analogRead(x); return val; } //////////////////////////////////////////////////// 6
VII Installation On DFRobotShop Rover We suggest mounting the sensor on one of the locations below outlines in red: Pinout: ● Out1 : Right Sensor analog output to Analog pin 2 on Arduino ● Out2 : Left Sensor analog output to Analog pin 1 on Arduino ● Out3 : Middle Sensor analog output to Analog pin 0 on Arduino ● VCC : +5V ● GND : Ground 7
There are many possible ways to mount the DFRobotShop Rover Line Sensor.
3) Screw on the other end of the F/F 1'' x 1/4'' Standoff with the DFRobotShop Rover Line Sensor to the 1/4'' x 440 Screw on the rover (The wires can be passed through the hole in front of the rover) : 4) Insert 2 pin headers to the power wires (Red and Black) and 3 pin headers to the output wires (Yellow, Blue and Purple).
VIII Questions/Troubleshooting For questions or troubleshooting, please contact us through our Forum or submit a ticket via our Support Center .