Grove - Line Finder

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

Previous Version: v0.9b




With Arduino

The brick will return HIGH when black line is detected, and LOW when white line is detected. Using the adjustable resistor the detection range can be changed from 1.5cm to 5cm. If the sensor can’t tell between black and white surfaces, you can also use the adjustable resistor to set a suitable reference voltage.

Includes important code snippet. Demo code like :

Demo code
//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

With Raspberry Pi

1.You should have got a raspberry pi and a grovepi or grovepi+.

2.You should have completed configuring the development enviroment, otherwise follow here.


4.Navigate to the demos' directory:

   cd yourpath/GrovePi/Software/Python/
   nano   # "Ctrl+x" to exit #
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"

5.Run the demo.

   sudo python


Copyright (c) 2008-2016 Seeed Development Limited ( /
This static html page was created from