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
- Set up your connection as shown in the followinf image.
-
Connect ground pin to ground
-
Connect positive pin to arduino 5v
-
Connect output to ‘A5’ in the arduino board
-
In the setup()
1
2
3
4
|
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
|
- 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);
}
|