Skip to main content

Library Installation

Search for the Deneyap Cift Kanalli Cizgi Algilayici library in the Library Manager and install version 1.1.1 or later. For the installation steps, see the Library Installation page.

First Application

The code below calibrates the sensor for 10 seconds, then prints the position of the line to the serial monitor:

Basic Functions

Calibration

Each sensor reads the white surface and the black line differently depending on ambient light and the surface. During calibration the lightest (white) and darkest (black) value seen by each sensor is recorded. ReadCalibrated, ReadLineBlack and ReadLineWhite do not work before calibration.
1

Fix the height

Hold the module over the line with the sensors facing down, 3-5 mm above the surface. Keep the same height during calibration and use; calibrating with the module mounted on the robot, or resting on a fixed spacer, is recommended.
2

Call Calibrate() repeatedly

Call Calibrate() repeatedly for a few seconds. The KalibrasyonluCizgiTakibi example in the library does this for 10 seconds and turns the built-in LED on during that time.
3

Sweep the module across the line

Meanwhile, slowly sweep the module left and right across the line. Each of the 4 sensors must pass over both the white surface and the black line. If the module is mounted on a robot, you can rotate the robot left and right in place over the line.
4

Check the result

After calibration, check calibrationOn.minimum[] and calibrationOn.maximum[]. If the minimum and maximum of a sensor are very close, that sensor did not see the line; repeat the calibration.
Calibration values are not stored permanently; calibrate every time the board starts, and again if the lighting or the surface changes.
If the board is reset (upload, RESET button, opening the serial monitor) while it is talking to the module, the module may stop responding until its power is removed: begin() fails, or the module stops answering shortly after. Unplug the board’s USB cable and plug it back in to power-cycle the module. A short delay() between reads in loop() makes this less likely.

Examples

The 4Kanal_GP2S700HCP folder of the library contains two ready examples: SensorDegerleriniOkuma (reads the raw values) and KalibrasyonluCizgiTakibi (calibrates and calculates the line position). Examples for the first version module are in the 2Kanal_TCRT5000 folder.
The module uses the Everlight ITR1502SR40A sensor. The library and its example folder carry the name of its equivalent, the Sharp GP2S700HCP; there is no difference in use.