KY-033 Tracking sensor module

From SensorKit X40 Wiki

Jump to: navigation, search



Technical data / Short description

The sensor detects if a light reflecting or absorbing area is in front of it. It shows which of the 2 areas it is via digital output, as you can see in the picture below.
The Sensitivity (minimum range) of the sensor can be adjusted by the controller.

This behavior can be used to automatically follow a line with a robot.

Condition 1: Line Tracker is on a line (not reflecting area) [LED on the module: Off] [Sensor signal= Digital On]

KY-033 LineOn.jpg

Condition 2: Line Tracker not on a line (reflecting area) [LED on the module: ON] [Sensor signal= Digital Off]

KY-033 LineOff.jpg


3 S V G.png

Code example Arduino

int Sensor = 10; // Declaration of the sensor input pin
void setup ()
  Serial.begin(9600); // Initialization serial output
  pinMode (Sensor, INPUT) ; // Initialization sensor pin
// The program reads the status of the sensor pins
// shows via serial terminal if the linetracker is on the line or not
void loop ()
  bool val = digitalRead (Sensor) ; // The current signal of the sensor will be read
  if (val == HIGH) // If a signal is detected the LED will light up.
    Serial.println("LineTracker is on the line");
    Serial.println("Linetracker is not on the line");
  delay(500); // Break of 500ms between the measurements 

Connections Arduino:

Sensor signal = [Pin 10]
Sensor +V = [Pin 5V]
Sensor GND = [Pin GND]

Example program download


Code example Raspberry Pi

# Needed modules will be imported and configured
import RPi.GPIO as GPIO
import time


# Declaration of the input pin which is connected with the sensor
GPIO.setup(GPIO_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)

# Break between the results will be defined here (in seconds)
delayTime = 0.5

print "Sensor-Test [press ctrl+c to end]"

# main program loop
        while True:
            if GPIO.input(GPIO_PIN) == True:
                print "LineTracker is on the line"
                print "Linetracker is not on the line"
            print "---------------------------------------"

            # Reset + Delay

# Scavenging work after the end of the program
except KeyboardInterrupt:

Connections Raspberry Pi:

Signal = GPIO24 [Pin 18]
+V = 3,3V [Pin 1]
GND = GND [Pin 6]

Example program download


To start, enter the command:

sudo python