We are going to detect white line using a KY-033 Sensor.

Pins

This module has 3 pins.GRD, OUT, VCC.

Components Required

  • Arduino uno
  • KY-033 Tracking Sensor
  • 3 jumper wires

Procedure

  1. Set up your connection as shown in the followinf image.

joy stick connecting image

  1. Connect ground pin to ground

  2. Connect positive pin to arduino 5v

  3. Connect output to ‘A5’ in the arduino board

  4. In the setup()

1
2
3
4
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}
  1. In the loop() function write:
1
2
3
4
5
6
7
8

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 5
  int sensorValue = analogRead(A5);
  // print out the value you read:
  Serial.println(sensorValue);
} 

Full source Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 5:
  int sensorValue = analogRead(A5);
  // print out the value you read:
  Serial.println(sensorValue);
}