Grove-Line finder is designed for line-following robot. It has an IR emitting LED and an IR sensitive phototransistor. It can output digital signal to a microcontroller so that the robot can follow a black line on white background, or vice versa.


Product Version Changes Released Date
Grove-Line Finder V1.0 Initial Jan 29 2010
Grove-Line Finder V1.1 Add test points Dec 28 2015


Parameter Value/Range
Power supply 5
Digital output mode TTL (High when black is detected, Low when white is detected)
Connector 4 pin Buckled Grove interface
Dimension 20mm*20mm
Photo reflective diode RS-06WD
Comparator MV358


More details about Grove modules please refer to Grove System

Platform Supported

Arduino Raspberry Pi


The platforms mentioned above as supported is/are an indication of the module's software or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Getting Started

Play With Arduino


  • Step 1. Prepare the below stuffs:
Seeeduino V4.2 Base Shield Grove - Button
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now
  • Step 2. Connect Grove-line finder to port D3 of Grove-Base Shield.
  • Step 3. Plug Grove - Base Shield into Seeeduino.
  • Step 4. Connect Seeeduino to PC through a USB cable.


If we don't have Grove Base Shield, We also can directly connect Grove-Line finder to Seeeduino as below.

Seeeduino Grove-Line finder
5V Red
GND Black
Not Conencted White
D3 Yellow


  • Step 1. Copy the code into Arduino IDE and upload.
//Name: Line finder digital mode
//Function: detect black line or white line
//Parameter:   When digital signal is HIGH, black line
//             When digital signal is LOW, white line
int signalPin =  3;    // connected to digital pin 3
void setup()   {
  pinMode(signalPin, INPUT); // initialize the digital pin as an output:
  Serial.begin(9600);  // initialize serial communications at 9600 bps:
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
  if(HIGH == digitalRead(signalPin))
  else  Serial.println("white");  // display the color
  delay(1000);                  // wait for a second
  • Step 2. Open the serial port and we will see "black" when put the sensor on top of black lines and "white" when on white area.

Play with Codecraft


Step 1. Connect a Grove - Line Finder to port D3 of a Base Shield.

Step 2. Plug the Base Shield to your Seeeduino/Arduino.

Step 3. Link Seeeduino/Arduino to your PC via an USB cable.


Step 1. Open Codecraft, add Arduino support, and drag a main procedure to working area.


If this is your first time using Codecraft, see also Guide for Codecraft using Arduino.

Step 2. Drag blocks as picture below or open the cdc file which can be downloaded at the end of this page.


Upload the program to your Arduino/Seeeduino.


When the code finishes uploaded, you will see line found or not in Serial Monitor.

Play With Raspberry Pi


  • Step 1. Prepare the below stuffs:
Raspberry pi GrovePi_Plus Grove - Line Finder
enter image description here enter image description here enter image description here
Get ONE Now Get ONE Now Get ONE Now
  • Step 2. Plug the GrovePi_Plus into Raspberry.
  • Step 3. Connect Grove-Line Finder to D7 port of GrovePi_Plus.
  • Step 4. Connect the Raspberry to PC through USB cable.


  • Step 1. Follow Setting Software to configure the development environment.
  • Step 2. Git clone the Github repository.

cd ~
git clone https://github.com/DexterInd/GrovePi.git
- Step 3. Excute below commands.

cd ~/GrovePi/Software/Python
python grove_line_finder.py

Here is the grove_line_finder.py code.

import time
import grovepi

# Connect the Grove Line Finder to digital port D7
line_finder = 7


while True:
        # Return HIGH when black line is detected, and LOW when white line is detected
        if grovepi.digitalRead(line_finder) == 1:
            print ("black line detected")
            print ("white line detected")


    except IOError:
        print ("Error")
  • Step 4. We will see black line detected when the sensor is on top of black line.
pi@raspberrypi:~/GrovePi/Software/Python $ python grove_line_finder.py 
black line detected
black line detected
white line detected
white line detected

Grove-Line Finder Schematic V1.0

Grove-Line Finder Schematic V1.1


Tech Support

Please submit any technical issue into our forum.