edit

Grove - Line Finder

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.

Version

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

Specification

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
ROHS Yes
Photo reflective diode RS-06WD
Comparator MV358

Tip

More details about Grove modules please refer to Grove System

Platform Supported

Arduino Raspberry Pi BeagleBone Wio LinkIt ONE

Caution

The platforms mentioned above as supported is/are an indication of the module's hardware 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

Hardware

  • 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.

Note

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

Software

  • 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))
    Serial.println("black");
  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.
white
white
white
black
black
black
black
black

Play With Raspberry Pi

Hardware

  • 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.

Software

  • 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
# SIG,NC,VCC,GND
line_finder = 7

grovepi.pinMode(line_finder,"INPUT")

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

        time.sleep(.5)

    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

Resources

Tech Support

Please do not hesitate to contact techsupport@seeed.cc if you have any technical issue. Or submit the issue into our forum.