Difference between revisions of "KY-033 Tracking sensor module"

From SensorKit X40 Wiki

Jump to: navigation, search
(Created page with "==Picture== none ==Technical data / Short description== The sensor detects if a light reflecting or absorbing area is in front of it. It shows which of t...")
 
(No summary)
Line 1: Line 1:
 
==Picture==
 
==Picture==
[[Datei:ky-033.jpg|none]]
+
[[File:ky-033.jpg|358x358px|none]]
  
 
==Technical data / Short description==
 
==Technical data / Short description==
Line 10: Line 10:
 
<u>'''Condition 1''': Line Tracker is on a line (not reflecting area) [LED on the module: Off] [Sensor signal= Digital On]</u>
 
<u>'''Condition 1''': Line Tracker is on a line (not reflecting area) [LED on the module: Off] [Sensor signal= Digital On]</u>
  
[[Datei:KY-033_LineOn.jpg|none]]
+
[[File:KY-033_LineOn.jpg|600x337px|none]]
  
  
 
<u>'''Condition 2''': Line Tracker not on a line (reflecting area) [LED on the module: ON] [Sensor signal= Digital Off]</u>
 
<u>'''Condition 2''': Line Tracker not on a line (reflecting area) [LED on the module: ON] [Sensor signal= Digital Off]</u>
  
 [[Datei:KY-033_LineOff.jpg|none]]
+
 [[File:KY-033_LineOff.jpg|600x337px|none]]
  
  
  
 
==Pinout==
 
==Pinout==
[[Datei:3_S_V_G.png|none]]
+
[[File:3_S_V_G.png|none]]
  
 
==Code example Arduino==
 
==Code example Arduino==

Revision as of 16:26, 6 March 2017

Picture

ky-033.jpg

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, how you can see in the picture below. The Sensitivity (minimum range) of the sensor could be controlled by the controller.

This behavior could 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


Pinout

3 S V G.png

Code example Arduino

The program reads the current status of the sensor pin and gives it out via serial terminal if the linetracker in on a line or not.

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");
  }
  else
  {
    Serial.println("Linetracker is not on the line");
  }
  Serial.println("------------------------------------");
  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

KY-033_TrackingSensor.zip

Code example Raspberry Pi

This program reads the status of the sensor pin and shows via serial terminal if the linetracker is on the line or not.

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

GPIO.setmode(GPIO.BCM)

# Declaration of the input pin which is connected with the sensor
GPIO_PIN = 24
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
try:
        while True:
            if GPIO.input(GPIO_PIN) == True:
                print "LineTracker is on the line"
            else:
                print "Linetracker is not on the line"
            print "---------------------------------------"

            # Reset + Delay
            time.sleep(delayTime)

# Scavenging work after the end of the program
except KeyboardInterrupt:
        GPIO.cleanup()

Connections Raspberry Pi:

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

Example program download

KY-033_RPi_Trackingsensor.zip

To start with the command:

sudo python KY-033_RPi_Trackingsensor.py