Description
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.
Pinout
Code example Arduino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
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] |
Second Example Code:
int sensorPin = A5; / / select the input pin
int ledPin = 13; / / select the pin for the LED
int sensorValue = 0; / / variable to store the value coming from the
sensor
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
delay(sensorValue);
digitalWrite(ledPin, LOW);
delay(sensorValue);
Serial.println(sensorValue, DEC);
}
Reviews
There are no reviews yet.