Arduino Projects

KY-033 Line Tracking Sensor Arduino circuit and programming

KY-033 Line tracking sensor with arduino:

KY-033 Line tracking sensor– A line tracking sensor and it does exactly what the name suggests it tracks black lines against white background or white lines against black background whatever you would like to do and it’s a pretty simple device. This sensor is also known as hunt sensor or line following sensor. I just want to talk a little bit about what these things can do and how they should be used with the Arduino. This sensor consists of IR. This is basically obstacle sensing module having built-in receiver and transmitter that senses the IR energy and looks for the reflected IR energy to detect the obstacle in front of the sensor module. The sensor returns the status of the IR light reflected from the surface. So it’s a pretty simple device it has got an infrared receiver and an infrared transmitter. So the transmitter is constantly transmitting infrared pulses and the receiver is looking for those pulses to receive when reflected. When this line tracking sensor is on a black surface then all of the radiation that’s been transmitted gets absorbed by the surface and nothing is reflected onto the sensor and so we get a zero output signal and when it is on a white surface the opposite happens all of the radiation that is transmitted off the transmitter is being detected by the receiver and then we get a positive signal or a digital one. There is a knob that you can use it goes from one to three and you can use this to adjust the sensitivity of the line tracking sensor. A line tracking sensor consists of three pins in which one pin is ground, one is VCC and other pin is the output of the sensor.

ky-033 line tracking Sensor

SPECIFICATION

  • Working voltage: DC 3.3V-5V
  • Working current: ≥ 20mA
  • Operating temperature: -10℃~+50℃
  • Detection distance: 2-40cm
  • IO Interface:3-wire interfaces
  • Output signal: TTL level (low level there is an obstacle, no obstacle high)
  • Adjustment: adjust multi-turn resistance
  • Effective angle: 35°



Inside the KY-033 line tracking sensor:

ky-033 line tracking Sensor

This module has integrated onboard a line tracker, on board built-in potentiometer which will be used to adjust the detection range, one microchip, four resistors and one led. The potentiometer is used to calibrate the sensor. The sensor has very good ambient response even in complete darkness. The resistor R1 used in this module is 1.5 kilo ohms, resistor R3 is 10 kilo ohm, the resistor R4 is 220 ohms and the resistor R5 is 10 kilo ohm and the main reason for using the resistors is to limit current circulating inside the module. In other words to prevent current from burning our module the LED l1 is used in this module to show us if the module is in the lane or not now I will show how this components are connected together. There we have the sensor itself and of course the four resistors and the LED d1 on the right you can see how the pins of the module are connected on this board we have in black wire for the flow of the ground we have in red wire for the flow of the voltage and of course we have in green for the flow of the signal.




KY-033 Line Tracking sensor with the arduino:

So let’s go ahead and connect this line tracking sensor with the Arduino Uno and now connect the output pin of the sensor with digital pin 8 of the Arduino. Now connect the ground of the sensor with the ground of the arduino and VCC with the 5V of the arduino.  These are the very basic connections that you can start with to fully understand the functionality of the line tracking sensor.

ky-033 line tracking Sensor

When we will plug the sensor with the Arduino it will start blinking but the blue light is only blinking when I put my hand too close to the sensor. This led shows the status of the sensor.

ky-033 line tracking Sensor

Working of the sensor:

So what I have here actually is a test track that I had made for the line tracking sensor or Line Following Sensor and I have got some lines that are made by a marker and then I have got one line that’s made out of electrical tape. I just wanted to see how the sensor does in different conditions with different materials. So let’s go ahead when I put it on a black surface it goes blank and goes in a white surface gives me a blue light.

ky-033 line tracking Sensor

So let’s go over Arduino ide and write a simple code and see what we get all right.


KY-033 Line Tracking Sensor Arduino Code:

void setup() 
{
Serial.begin(9600); // activates Serial Communication
}

void loop() 
{
Serial.print(digitalRead(8)); // Line Tracking sensor is connected with pin 8 of the Arduino
delay(500);
}

so this is the code believe it or not just about two lines of code we read from digital pin 8 and we print it out to the serial monitor and so let’s go ahead run our code when the code is uploaded to the arduino so let’s go to the serial monitor and see what we get? we’re getting a series of ones and zeros; so, while it is on the black line we should get a one and when it’s not we should get a zero as you can see works pretty well.

ky-033 line tracking Sensor

So you can actually make one of this sensor yourself using an infrared transmitter and a receiver. This is simply amazing, how easily we can detect the black and white. Let’s take this to the next level and control a buzzer. You can also replace the buzzer with a small dc motor to a relay, infact anything you want.

Line tracking sensor KY-033  with arduino and buzzer:

In this example, we will connect the line tracking sensor KY-033 with the arduino to control a buzzer.

Component Required:

  • Line tracking sensor KY-033
  • Arduino UNO
  • 5V buzzer
  • 2 LEDs
  • 2 Resistors 220 ohm



KY-033 Arduino Circuit connection:

ky-033 line tracking Sensor

  • Connect the ground of the line tracking senor with ground of the Arduino
  • Connect the output pin of the line tracking senor with the digital pin 2
  • Connect the VCC of the line tracking sensor with 5 V of the arduino
  • Now connect the digital pin d3 of the arduino with one terminal of the 220 ohm resistor and connect the other terminal of the resistor with the anode of the led and connect the cathode of the led with the ground.
  • Similarly connect the digital pin d4 of the arduino with one terminal of the 220 ohm resistor and connect the other terminal of the resistor with the anode of the led and connect the cathode of the led with the ground.
  • Now connect the digital pin 5 of the arduino with positive terminal of the buzzer and connect the negative terminal of the buzzer with the ground..

KY-033 Line Tracking Sensor Arduino Code:

#define sensor 2
#define buzzer 3
#define red 4
#define green 5

void setup() {
Serial.begin(9600);
pinMode(sensor,INPUT);
pinMode(buzzer,OUTPUT);
pinMode(green,OUTPUT);
pinMode(red,OUTPUT);


}

void loop() {
bool value = digitalRead(sensor);
if(value == 0)
{
  digitalWrite(buzzer, HIGH);
    digitalWrite(green, HIGH);
      digitalWrite(red, HIGH);

}
else
{
    digitalWrite(buzzer, LOW);
    digitalWrite(green, LOW);
      digitalWrite(red, LOW);
  }
}


Working of the line tracking sensor:

After uploading the code, to test the circuit we can use the same white background and black color line. When the Line tracking Sensor detects the white surface the Arduino turns on the Buzzer and the LED. When the Line tracking Sensor detects the Black line or surface the buzzer turns off and also the LED is turned is turned off.

Now, after understading the basics and how to use the line tracking sensor, now you can make a line follwer robot. Now, you can use two line tracking sensors on both sides of the line you want to track and then accordingly you can control the two motors of the line following robot.

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button