5-Channel Line Tracker Library for Proteus Simulation: the tracker bar, an I2C LCD 16x2 and motor LEDs on an Arduino UNO V4.0

5-Channel Line Tracker Library for Proteus Simulation

40
700
60
25
60
PCBWay

Hello friends, I hope you all are doing great. Today, I am going to share the new 5-Channel Line Tracker Library for Proteus Simulation. A line-following robot needs eyes on the floor, and this is the classic set: a bar with five reflective infrared sensors that see a black line on a white floor, plus a front obstacle sensor and a bump switch. With this library you can run a full Proteus simulation of the bar on a whole course - curves, a junction, a gap, an obstacle and a collision - and write and test the brain of your robot before it ever touches the floor.

5-channel line tracker Proteus simulation: a line follower brain with an I2C LCD and motor LEDs on an Arduino UNO V4.0
Figure: The line tracker simulation running: a curve, a cross line, a sharp curve, a gap, an obstacle and a bump.
Updates

5-Channel Line Tracker Library for Proteus

Latest version: V1.0 (December 2026, this tutorial)

Helping Tools

The demo is that brain: an Arduino UNO V4.0 reads the five channels, works out where the line is, steers two motors with a PD controller (shown as two green LEDs whose brightness is the motor speed), handles a lost line and a cross line, slows down for an obstacle, stops on a bump and shows everything on a 16x2 LCD.

NOTICE: Our team has put a lot of effort into these small parts: the bodies, the animation and the pop-ups are all our own design, and you get them free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the infrared sensor board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the 5-Channel Line Tracker Library for Proteus Simulation:

5-Channel Line Tracker Library for Proteus Simulation: the tracker bar, an I2C LCD 16x2 and motor LEDs on an Arduino UNO V4.0
Figure: The 5-Channel Line Tracker Library for Proteus Simulation.

What Is a 5-Channel Line Tracker?

Each channel of the bar is a TCRT5000 reflective sensor - an infrared LED and a phototransistor side by side, looking down at the floor. White floor returns plenty of infrared, black tape very little, so each channel can tell whether it is above the line or not. With five of them about 15 mm apart, the bar sees not only whether the line is there but where: under the middle sensor, slightly to one side, or far out under an end sensor. That position is exactly what a robot needs to steer. The single-sensor version, with its analog output and trimmer, has its own post: our TCRT5000 IR Sensor Library for Proteus.

This version of the bar adds two things at the front. NEAR is a forward-looking infrared pair that goes HIGH when an obstacle comes within its range, set by a small trimmer between 0 and 5 cm. CLP is a micro-switch with a lever across the front - a bumper - that goes HIGH when the robot actually hits something. Together they let the robot slow down before a collision and stop if one happens anyway.

The Pins

The nine-pin header carries VCC (3.0 to 5.5 V), GND, CLP, NEAR and the five channel outputs S1 to S5. Each S output is LOW over black and HIGH over white, and its red LED on the bar lights over black, so you can check the line's position by eye. The line channels have no trimmers: their switching point is fixed on the board, which is why the height above the floor matters.

Height, Line Width and the Floor

The TCRT5000 sees best at a few millimetres. Mounted 3 to 10 mm above the floor the bar tells black from white easily; much higher, the light from white floor gets so weak that it looks like black and every channel reads LOW. The line should be about as wide as the sensor spacing - 15 to 20 mm of matt black electrical tape on a white or light floor is the usual choice. A line much narrower than the spacing can slip between two sensors; a much wider one covers three at once.

From Five Bits to a Position

The common way to turn five channels into one number is a weighted average. Give the channels the weights 0, 1000, 2000, 3000 and 4000 and average the weights of the black ones: the line under S3 gives 2000, between S2 and S3 gives 1500, under S5 gives 4000. The error is the position minus 2000, and the controller turns it into a speed difference between the motors. Two special cases need their own rules: when no channel sees black the line is lost, and the robot should keep turning the way the line was last seen; when four or five see black it is a cross line or the finish.

Features of the Line Tracker Library

  • A real-looking bar: the module at its true size with five sensors, the NEAR pair, the bump switch and the header; the channel LEDs, the NEAR LED and the PWR LED light at Run.
  • Five real channels: each with the TCRT5000's distance curve at the bar's HEIGHT and a Schmitt decision, LOW over black.
  • NEAR and CLP: the obstacle within RANGE and the bump switch, both active HIGH.
  • A course: the DEMO run brings curves, a cross line, a gap, an obstacle and a bump; STEADY puts the line at OFFSET; the pop-up moves the line or adds an obstacle at any time.
  • A pop-up: the floor under the bar seen from above, the five sensors and the obstacle ahead; graphs, an event log and a check page.
  • A complete package: about 2.4 MB with the library, our I2C LCD, resistors and LEDs, our Arduino UNO V4.0 and the demo, without the source code of the model.

The Line Tracker in Proteus

The device is LINETRACKER5TEP in TEPTRACKER5.LIB, under Modules > Sensors, with the model TEPTRACKER5.DLL. Search TRACKER or line in Pick Devices. Its nine pins are the header of the real bar. Four properties set it up: PROFILE (DEMO or STEADY), HEIGHT (mm above the floor), OFFSET (the line's position for STEADY) and RANGE (the NEAR trimmer, cm).

5-channel line tracker bar from the Line Tracker Library for Proteus Simulation, with five sensors, the obstacle sensor and the bump switch
Figure: The tracker bar.

Download 5-Channel Line Tracker Library for Proteus Simulation

Click the button below to download 5-Channel-Line-Tracker-Library-for-Proteus-v1.0.zip (about 2.4 MB, without the source code of the models):

5-Channel Line Tracker Library for Proteus V1.0
  • README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
  • Proteus Library Files: TEPTRACKER5.LIB, TEPI2CLCD16X2.LIB, TEPRESISTOR.LIB, TEPLED5MM.LIB and ArduinoV4TEP.LIB.
  • Proteus Model Files: TEPTRACKER5.DLL, TEPLCD.DLL, TEPRESISTOR.DLL, TEPLED5MM.DLL and TEPARDUINO.DLL.
  • Arduino Code: the demo sketch (Wire only).
  • Proteus Simulation: the demo project, its HEX file and copies of the DLLs.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install 5-Channel Line Tracker Library for Proteus Simulation

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the files from Proteus Model Files into the MODELS folder.
  4. Delete TEPTRACKER5.IDX from the LIBRARY folder if it is there.
  5. Start Proteus, press P and search for TRACKER.

Proteus Simulation of a Line Follower

The demo uses an A4 sheet with our Arduino UNO Library for Proteus V4.0. The tracker bar (U1) sits at the top right: S1 to S5 go to D3 to D7, NEAR to D8 and CLP to D2. A 16x2 LCD from our I2C LCD 16x2 Library for Proteus shares the I2C bus at 0x27. Instead of real motors the demo shows the two motor commands as the brightness of two green LEDs on the PWM pins D9 (left) and D10 (right), with a red STOP LED on D12; in a robot those two PWM signals would go to a driver such as our L298N Motor Driver Library for Proteus. The Arduino's monitor is built in, the same window as our TEP Serial Monitor Advance for Proteus. Open Line-Follower-Tracker-ArduinoUnoV4.pdsprj. The course is part of the DEMO: a recorded run of a robot, seen from the bar.

Line tracker simulation in Proteus: the 5-channel tracker bar, an I2C LCD 16x2 and motor and stop LEDs on an Arduino UNO V4.0, A4 sheet
Figure: The whole simulation on an A4 sheet.

The Sketch

Every 20 ms the sketch reads the five channels; LOW means the line is under that channel, and the black channels add their weights:

    const bool b = digitalRead(S_PIN[i]) == LOW;             // LOW = the black line under this channel

Four or more black channels are a cross line, no black channel is a lost line, and otherwise the position is the average. While the line is seen off-centre, the sketch also remembers on which side:

  else { position = lastSide < 0 ? 0 : lastSide > 0 ? 4000 : 2000; state = "LOST"; }   // lost: keep turning the way it was last seen

The PD controller is two lines - the proportional part reacts to the error, the derivative part to how fast it changes:

  const int error = position - 2000;
  const int turn = KP * error + KD * (error - lastError);

NEAR lowers the base speed and CLP sets it to zero before the motor commands are written.

Line Tracker Simulation Results

Open the project and press Run. The demo runs 5.9 simulated seconds and took about 2 minutes 40 seconds on our PC with the pop-up open and the pictures being taken. Click U1 for its pop-up. Every number below comes from one simulation run, the demo exactly as it ships.

Straight On and a Curve to the Right

The run starts on a straight line under the middle sensor: S3 is LOW, the other four HIGH, the position is 2000, the error 0, and both motors get the cruising speed of 150. At 0.6 s the course bends to the right and the line drifts towards S4 and S5. At 1.3 s it is 20 mm right of centre, right under S4: the LCD shows "...#. P3000 RUN" and "L200 R100 e+1000" - the left motor speeds up and the right one slows down, so the robot turns towards the line. The pop-up at 1.28 s shows the line under S4, its LED lit on the bar.

Line tracker Proteus simulation pop-up: the line under S4 in a curve to the right
Figure: A curve to the right.
Line tracker Proteus simulation: the bar with the S4 LED lit over the line
Figure: The bar on the course.
The 5-channel line tracker simulation running in the Proteus workspace
Figure: The simulation in the workspace.

A Cross Line

At 2.0 s a cross line passes under the bar - a junction on the course. For 0.15 s all five channels are black, the pop-up at 2.07 s shows "ALL BLACK - S1-S5 00000" and the controller, which runs every 20 ms, sees four or more black channels and holds the position at 2000: straight on. By the next monitor line, at 2.13 s, the cross line is behind the robot and only S3 sees the line again.

Line tracker Proteus simulation pop-up: a cross line under the bar, all five channels black
Figure: A cross line.

A Sharp Curve to the Left

From 2.4 s the course turns sharply left. The monitor follows the line across the bar: ".#..." and position 1000 at 2.55 s (left motor 100, right motor 200), then "#...." and position 0 at 2.76 s and 2.97 s - the line under S1, the robot turning hard with 50 and 250. The pop-up at 2.89 s shows the line 26 mm left of centre, beyond S1's centre, with only S1 black. At 3.18 s the line is back under S2.

Line tracker Proteus simulation pop-up: the line beyond S1 in a sharp curve to the left
Figure: A sharp curve to the left.

A Gap in the Line

At 3.4 s the line simply stops - a gap in the tape. All five channels see white, the pop-up's banner turns amber, "NO LINE", and the monitor prints "....." and LOST. The sketch remembers that the line was last seen on the left, so it keeps the position at 0 and turns left: 0 and 255 at 3.38 s, 50 and 250 at 3.59 s. That is the right guess here - when the tape starts again at 3.8 s the line is 10 mm left of centre, under S2. Notice the jump at 3.80 s: the position goes from 0 to 1000 in one step, the derivative term sees a sudden change of 1000 and swings the motors to 255 and 0 for a moment. That is the D term's well-known "kick"; real code often filters it. By 4.01 s the line is between S2 and S3 (".##..", position 1500) and from 4.22 s the robot runs straight again.

Line tracker Proteus simulation pop-up: a gap in the line, all five channels white
Figure: A gap in the line.

An Obstacle, and a Bump

From 4.6 s an obstacle approaches at 20 cm per second. At 5.35 s it is 5 cm away, the end of the NEAR range: NEAR goes HIGH, its green LED lights on the bar, and the sketch slows both motors to 70 - "SLOW" at 5.47 s. The pop-up at 5.40 s shows the obstacle 4.0 cm ahead inside the shaded range.

Line tracker Proteus simulation pop-up: an obstacle ahead within the NEAR range
Figure: An obstacle ahead.

At 5.55 s the robot touches the obstacle and the bump switch closes: CLP goes HIGH, the sketch stops both motors and lights the red STOP LED - "BUMP" with 0 and 0 at 5.68 s. The pop-up at 5.88 s shows the red banner "BUMP - CLP HIGH" with the line still under S3: the robot was on its line, but something stood in its way.

Line tracker Proteus simulation pop-up: the bump switch pressed, CLP high
Figure: The bump.

The Graphs, the Event Log and the Check Page

The Graphs page plots the line's true position under the bar, the black channels as a number, the obstacle's distance and NEAR and CLP. The Event log lists the course - the cross line, the gap, the line again, the obstacle and the bump. The Check page sums up the run: the supply at 5.00 V; the height of 8 mm, where white gives 0.438 mA and black 0.036 mA against the switching point of 0.15 mA, so black and white are told apart; the five channels now, 11011, and the number of channel changes during the run; and NEAR and CLP both HIGH at the end.

Line tracker Proteus simulation graphs: the line position, the black channels, the obstacle distance and NEAR / CLP
Figure: The Graphs page.
Line tracker Proteus simulation Event log: the cross line, the gap, the obstacle and the bump
Figure: The Event log.
Line tracker Proteus simulation Check page after the demo run
Figure: The Check page.

The Arduino's built-in serial monitor prints a line every 200 ms: the time, the five channels as a little picture (# for black), the position, the two motor speeds and the state - RUN, CROSS, LOST, SLOW or BUMP. The whole run can be read back from it, line by line.

Arduino UNO V4.0 serial monitor in the line tracker Proteus simulation: the channels, the position, the motors and the state
Figure: The Arduino's monitor.

Tuning the PD Controller

KP sets how hard the robot steers for a given error. Too small and it drifts off in curves; too large and it swings from side to side. KD damps that swinging by reacting to how quickly the error changes - but it also reacts to sudden jumps, as the kick after the gap shows. Start with KD at zero, raise KP until the robot just starts to wobble, then add KD until the wobble disappears. With the digital outputs of this bar the position moves in steps of 500 to 1000, so modest gains work best; boards with analog outputs give a smoother position.

Why Not Just Two Sensors?

A two-sensor robot can follow a gentle line, but it only knows "too far left" or "too far right". Five channels give five or more positions, so the robot can steer gently for a small error and hard for a large one, recognise a junction and remember where it lost the line. That is the difference between a robot that zig-zags and one that flows.

Try It Yourself

  • Click U1 while the simulation runs and use the chips: Line centre, Line left and Line right move the line; Obstacle 3 cm and Bump test the safety code.
  • Set HEIGHT to 20: white is too weak to beat the switching point, every channel reads black and the sketch thinks it is on a cross line.
  • Set RANGE to 2: the robot keeps full speed until the obstacle is 2 cm away.
  • Change KD to 0 in the sketch: no kick after the gap, but more swinging after the curves.
  • Set PROFILE to STEADY and OFFSET to 15: S4 alone sees the line, the position is 3000.

Ideas to Extend the Demo

  • Drive two DC motors through an L298N instead of the LEDs and build the robot.
  • Count the cross lines and stop at the third one.
  • Use NEAR to drive around the obstacle and find the line again.

Your Own Sketches

The demo sketch is in the zip file, and you can change it in the Arduino IDE. New to Arduino? Start with our Arduino Tutorial for Beginners. Export the compiled binary, and set the UNO's PROGRAM property to the new file. Our guide on How to get the HEX file from Arduino shows you where the file ends up.

Things to Know Before Using a Real Line Tracker

  • Height: mount the bar 3 - 10 mm above the floor and keep it parallel to it.
  • Line: matt black tape 15 - 20 mm wide on a white floor; glossy tape reflects and confuses the sensors.
  • Light: sunlight on the floor contains infrared - shade the bar.
  • Bumper: test CLP by hand and stop the motors first, then decide what to do.
  • Speed: the faster the robot, the more often it must read the bar - every 20 ms is a good start.

Troubleshooting

  • Every channel reads black: the bar is too high above the floor or the floor is not white.
  • Every channel reads white: the line is not under the bar, or it is too narrow.
  • The robot turns away from the line: S1 and S5 are swapped, or the motors are.
  • NEAR never goes HIGH: the trimmer's range is shorter than the obstacle's distance.
  • The part is not simulated: TEPTRACKER5.DLL is missing from MODELS and from the project folder.

Limitations of the Simulation

  • The pins, the output polarity, NEAR and CLP follow the module's product pages - no maker datasheet exists - and each channel follows the TCRT5000 datasheet; the bar is our own drawing.
  • Our own figures: 15 mm between the sensors, an 18 mm line, the switching point and its hysteresis, the output strength and the DEMO course.
  • Not modelled: the robot itself - the DEMO is a recorded run, not a closed loop, so the motor LEDs do not move the line - sunlight, and the bumper's lever travel.
  • Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or any maker of the bar.
  • Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.

So, that was all about the 5-Channel Line Tracker Library for Proteus Simulation. I hope it helps you get your line follower's brain right on the screen, so the real robot follows its line on the first try. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!


Comments

0

Join the conversation