• Arduino
  • Raspberry Pi
  • Raspberry Pi Pico
  • Micro:Bit

This line tracking sensor module detects whether there is a light-reflecting or light-absorbing surface in front of the sensor and outputs the result at the digital output. This capability makes the module ideal for control systems such as those used in robots for autonomous line tracking. Robots can use this sensor to navigate precisely along predetermined paths by following reflective lines on the floor. The sensitivity of the sensor can be adjusted via two controllers to ensure optimal performance under different lighting conditions and surface conditions. This provides a reliable and customizable solution for a wide range of applications in robotics and automation.

State 1: Line tracker is over a line [LED on the module: Off] [Sensor Signal: Digital On].

State 2: Line Tracker is outside a line [LED on the module: On] [Sensor Signal: Digital Off].

Pin assignment


Arduino Sensor
5 V +V
GND GND
Pin 10 Signal

Code example

The program reads the current state of the sensor pin and displays in the serial console whether the line tracker is currently on the line or not.

To load the following code example onto your Arduino, we recommend using the Arduino IDE. In the IDE, you can select the appropriate port and board for your device.

Copy the code below into your IDE. To upload the code to your Arduino, simply click on the upload button.

int linetracking = 10; // Declaration of the sensor input pin
int value; // Temporary variable
   
void setup () {
  pinMode(linetracking, INPUT); // Initialization sensor pin
  digitalWrite(linetracking, HIGH); // Activation of internal pull-up resistor
  Serial.begin(9600); // Initialization of the serial monitor
  Serial.println("KY-033 Linetracking");
}
   
void loop () {
  // The current signal at the sensor is read out.
  value = digitalRead(linetracking);
  // If a signal could be detected, this is displayed on the serial monitor.
  if (value == HIGH) {
    Serial.println("Line recognized");
    delay(200); // 200 ms break
  }
}

This line tracking sensor module detects whether there is a light-reflecting or light-absorbing surface in front of the sensor and outputs the result at the digital output. This capability makes the module ideal for control systems such as those used in robots for autonomous line tracking. Robots can use this sensor to navigate precisely along predetermined paths by following reflective lines on the floor. The sensitivity of the sensor can be adjusted via two controllers to ensure optimal performance under different lighting conditions and surface conditions. This provides a reliable and customizable solution for a wide range of applications in robotics and automation.

State 1: Line tracker is over a line [LED on the module: Off] [Sensor Signal: Digital On].

State 2: Line Tracker is outside a line [LED on the module: On] [Sensor Signal: Digital Off].

Pin assignment


Raspberry Pi Sensor
3,3 V [Pin 1] +V
GND [Pin 6] GND
GPIO 24 [Pin 18] Signal

Code example

The program reads the current state of the sensor pin and displays in the serial console whether the line tracker is currently on the line or not.

from gpiozero import DigitalInputDevice
import time

# Initialize the input pin to which the sensor is connected
sensor = DigitalInputDevice(24, pull_up=True)

# Pause between the output of the result is defined (in seconds)
delayTime = 0.5

print("Sensor test [press CTRL+C to end the test]")

# Main program loop
try:
    while True:
        if sensor.is_active:  # True if the pin is HIGH (LineTracker is above the line)
            print("LineTracker is outside the line")
        else:  # False if the pin is LOW (line tracker is outside the line)
            print("Line tracker is above the line")
        print("---------------------------------------")

        # Reset + Delay
        time.sleep(delayTime)

# Clean up after the program has been completed
except KeyboardInterrupt:
    print("Program was interrupted by user")

This line tracking sensor module detects whether there is a light-reflecting or light-absorbing surface in front of the sensor and outputs the result at the digital output. This capability makes the module ideal for control systems such as those used in robots for autonomous line tracking. Robots can use this sensor to navigate precisely along predetermined paths by following reflective lines on the floor. The sensitivity of the sensor can be adjusted via two controllers to ensure optimal performance under different lighting conditions and surface conditions. This provides a reliable and customizable solution for a wide range of applications in robotics and automation.

State 1: Line tracker is over a line [LED on the module: Off] [Sensor Signal: Digital On].

State 2: Line Tracker is outside a line [LED on the module: On] [Sensor Signal: Digital Off].

Pin assignment


Micro: Bit Sensor
Pin 1 Signal
3 V +V
GND GND

Code example

This is a sample program that outputs text serially when a signal is detected at the sensor.

	
		pins.setPull(DigitalPin.P1, PinPullMode.PullUp)
		basic.forever(function () {
		    if (pins.digitalReadPin(DigitalPin.P1) == 1) {
		        serial.writeLine("No line")
		        basic.pause(100)
		    } else {
		        serial.writeLine("Line detected")
		        basic.pause(100)
		    }
		})
	

Sample program download

microbit-KY-033.zip

This line tracking sensor module detects whether there is a light-reflecting or light-absorbing surface in front of the sensor and outputs the result at the digital output. This capability makes the module ideal for control systems such as those used in robots for autonomous line tracking. Robots can use this sensor to navigate precisely along predetermined paths by following reflective lines on the floor. The sensitivity of the sensor can be adjusted via two controllers to ensure optimal performance under different lighting conditions and surface conditions. This provides a reliable and customizable solution for a wide range of applications in robotics and automation.

State 1: Line tracker is over a line [LED on the module: Off] [Sensor Signal: Digital On].

State 2: Line Tracker is outside a line [LED on the module: On] [Sensor Signal: Digital Off].

Pin assignment


Raspbery Pi Pico Sensor
3.3V +V
GND GND
GPIO18 Signal

Code example

The program reads the current status of the sensor pin and outputs it in the serial output. Thus it can be determined whether the line tracker is on a line or not.

To load the following code example onto your Pico, we recommend using the Thonny IDE. All you have to do first is go to Run > Configure interpreter ... > Interpreter > Which kind of interpreter should Thonny use for running your code? and select MicroPython (Raspberry Pi Pico).

Now copy the code below into your IDE and click on Run.

# Load libraries
from machine import Pin
from time import sleep

# Initialization of GPIO18 as input
sensor = Pin(18, Pin.IN, Pin.PULL_UP)

print("KY-033 Line detection")

# Continuous loop for continuous serial output
while True:
    if sensor.value() == 0:
        print("No line recognized")
    else:
        print("Line recognized")

    print("------------------------------------------------------")
    sleep(1)