TCRT5000 IR Sensor Library for Proteus Simulation: the TCRT5000 module, an I2C LCD 16x2 and an Arduino UNO V4.0 as a tachometer

TCRT5000 IR Sensor 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 TCRT5000 IR Sensor Library for Proteus Simulation. The TCRT5000 is the little reflective sensor behind countless line-following robots, object counters and speed sensors: an infrared LED and a phototransistor look at a surface a few millimetres away, and the amount of light that comes back tells white from black, or something from nothing. With this library you can run a full Proteus simulation of the common TCRT5000 module with its comparator and trimmer, watch both of its outputs, and build a tachometer with your Arduino.

TCRT5000 IR sensor Proteus simulation: a tachometer with an I2C LCD on an Arduino UNO V4.0
Figure: The TCRT5000 simulation running: the disc at 1500 rpm, at 3000 rpm, running down and stopped.
Updates

TCRT5000 IR Sensor Library for Proteus

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

Helping Tools

The demo is a tachometer: a dark disc with one white mark turns 3 mm above the sensor, a motor runs it up to 1500 and 3000 rpm and lets it stop, an Arduino UNO V4.0 times every turn from the D0 output, and a 16x2 LCD shows the speed and how far the analog A0 signal swings.

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 TCRT5000 IR Sensor Library for Proteus Simulation:

TCRT5000 IR Sensor Library for Proteus Simulation: the TCRT5000 module, an I2C LCD 16x2 and an Arduino UNO V4.0 as a tachometer
Figure: The TCRT5000 IR Sensor Library for Proteus Simulation.

What Is the TCRT5000 IR Sensor?

The TCRT5000 is a reflective optical sensor: one small black housing with two windows side by side. Behind one is an infrared LED at about 950 nm, behind the other a phototransistor with a filter that blocks most visible light. Both look the same way. When a surface is in front of them, part of the LED's light bounces back into the phototransistor, and the phototransistor passes a current that grows with the light it receives. A white surface returns much more infrared than a black one, and a near surface more than a far one - that is all the sensor knows, and it is enough for an amazing number of jobs.

The distance matters a lot. The datasheet's curve shows the strongest signal with the surface 2.5 mm away. Closer than that, the two windows no longer see the same spot; farther away, the light spreads. The signal stays above half of its peak from about 0.3 to 7 mm and above a fifth of it from 0.2 to 15 mm. So the sensor works best a few millimetres from what it looks at - just above the floor for a line follower, just beside the wheel for a speed sensor.

The Module

On its own the TCRT5000 needs a few parts, and the common module brings them on a small board of 32 x 14 mm. A 1 kohm resistor feeds the LED. A 10 kohm resistor pulls the phototransistor's collector up to VCC, with a 100 nF capacitor from there to ground - that node is the A0 output. An LM393 comparator compares A0 with the voltage of a blue trimmer and drives the D0 output, an open collector with its own 10 kohm pull-up and an LED. A second LED shows the power, and an M3 hole lets you screw the board in place. The header has four pins: VCC, GND, D0 and A0.

A0 and D0

The two outputs answer the same question in two ways. A0 is analog and inverted: the more light comes back, the more current the phototransistor takes and the lower A0 falls. Over black or with nothing in front it sits near VCC; over white close by it drops nearly to 0 V. D0 is digital: LOW, with the D0 LED on, when A0 is below the trimmer's voltage - white or a near object - and HIGH over black or nothing. Turning the trimmer moves the switching point; set it between the A0 levels of your two surfaces and D0 does the deciding for you.

The capacitor on A0 has a side effect worth knowing: with 10 kohm it forms a 1 ms time constant. A mark that passes in less than about 0.3 ms cannot pull A0 down far enough, and fast pulses get lost. For a tachometer that means a wide enough mark; for a line follower it never matters.

Features of the TCRT5000 Library

  • A real-looking module: the board at its true size with the sensor, the LM393, the trimmer, the LEDs and the header; the power LED, the IR LED and the D0 LED light at Run.
  • The datasheet's distance curve: the signal against the distance, peaking at 2.5 mm.
  • A0 as on the real module: the phototransistor with its 10 kohm and 100 nF, saturating near 0 V.
  • D0 as on the real module: the comparator against the trimmer (THRESHOLD), an open collector with its pull-up.
  • Targets: the DEMO tachometer disc, or a STEADY surface at DISTANCE with REFLECT; the pop-up switches to white paper, black tape or nothing.
  • A pop-up: the disc turning, A0 as a scope with the threshold and D0; graphs, an event log and a check page.
  • A complete package: about 1.7 MB with the library, our I2C LCD, our Arduino UNO V4.0 and the demo, without the source code of the model.

The TCRT5000 in Proteus

The device is TCRT5000TEP in TEPTCRT5000.LIB, under Modules > Sensors, with the model TEPTCRT5000.DLL. Search TCRT5000 or reflective in Pick Devices. Its four pins are the header of the real module. Four properties set it up: PROFILE (DEMO or STEADY), DISTANCE (mm), REFLECT (the surface for STEADY: 0.9 white, 0.06 black) and THRESHOLD (the trimmer, in % of VCC).

TCRT5000 IR sensor module from the TCRT5000 Library for Proteus Simulation, with the sensor, the LM393, the trimmer and the header
Figure: The TCRT5000 module.

Download TCRT5000 IR Sensor Library for Proteus Simulation

Click the button below to download TCRT5000-IR-Sensor-Library-for-Proteus-v1.0.zip (about 1.7 MB, without the source code of the models):

TCRT5000 IR Sensor Library for Proteus V1.0
  • README.txt: installation, the demo, the wiring, troubleshooting and the limits of the simulation.
  • Proteus Library Files: TEPTCRT5000.LIB, TEPI2CLCD16X2.LIB and ArduinoV4TEP.LIB.
  • Proteus Model Files: TEPTCRT5000.DLL, TEPLCD.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 TCRT5000 IR Sensor 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 TEPTCRT5000.IDX from the LIBRARY folder if it is there.
  5. Start Proteus, press P and search for TCRT5000.

Proteus Simulation of a Tachometer

The demo uses an A4 sheet with our Arduino UNO Library for Proteus V4.0. The module (U1) is drawn at its true size - small next to the UNO, as it really is. Its D0 goes to D2, an interrupt pin, and its A0 to the UNO's A0. A 16x2 LCD from our I2C LCD 16x2 Library for Proteus sits on the I2C bus at 0x27. The Arduino's monitor is built in, the same window as our TEP Serial Monitor Advance for Proteus. Open TCRT5000-Tachometer-ArduinoUnoV4.pdsprj. The disc is part of the DEMO: a dark disc with one white mark, 3 mm above the sensor, on a motor that runs it up to 1500 rpm, then to 3000 rpm, and then lets it stop.

TCRT5000 simulation in Proteus: the TCRT5000 module, an I2C LCD 16x2 and an Arduino UNO V4.0 as a tachometer, A4 sheet
Figure: The whole simulation on an A4 sheet.

The Sketch

Every falling edge of D0 is the white mark arriving - one turn. As in our Geiger Counter Library for Proteus, an interrupt does the counting; here it also timestamps each turn and keeps the time since the last one, ignoring edges closer than 2 ms, which a real comparator can produce at a slow edge:

  if (turns && now - lastEdge < DEBOUNCE_US) return;
  if (turns) period = now - lastEdge;

The speed is one minute divided by the time of one turn, rounded; if no turn has come for half a second the disc has stopped:

  const bool stopped = n < 2 || micros() - last > 500000UL;
  const unsigned long rpm = stopped ? 0 : (60000000UL + p / 2) / p;

Between the updates the loop reads A0 as fast as it can and keeps the lowest and the highest value, which shows how far the signal swings around the trimmer's threshold:

  const int a = analogRead(IR);                              // A0: high over black, low over white

TCRT5000 Simulation Results

Open the project and press Run. The demo runs 5.6 simulated seconds and took about 2 minutes 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.

The Disc Starts

For the first 0.4 s the disc stands still with its black side over the sensor. Black reflects about 6 % of the infrared, so the phototransistor carries only 0.074 mA, A0 sits at 4.26 V - 10 kohm times 0.074 mA below the 5 V supply - and D0 is HIGH with the D0 LED dark. Then the motor starts and the white mark comes round for the first time: A0 dives towards 0 V, crosses the 2.50 V threshold, and D0 goes LOW for the length of the mark. The sketch prints its first speeds while the motor runs up - 943 rpm at 1.05 s, 1339 rpm at 1.30 s - and from 1.55 s on it reads a steady 1500 rpm.

1500 rpm

The pop-up at 1.9 s shows the disc at 1500 rpm, 25 turns a second, and the scope tells the whole story of one turn in its 48 ms window: 40 ms of black at 4.26 V, then the white mark - A0 falls to 0.04 V and stays there while the mark passes, D0 drops LOW below it - and then A0 climbs back along the curve of the 100 nF charging through 10 kohm. The threshold line in amber sits in the middle of the swing, so every mark gives one clean pulse. 25 pulses so far, and the speed from them is 1500 rpm.

TCRT5000 Proteus simulation pop-up: the disc at 1500 rpm, A0 dipping below the threshold at the white mark and D0 going low
Figure: The disc at 1500 rpm.

3000 rpm

From 2.4 s the motor speeds up to 3000 rpm - the sketch follows with 1814, 2508 and then 3002 rpm at 3.05 s, and holds 3001 to 3002 rpm for a second. At 50 turns a second the mark passes in 1.7 ms, and the scope shows two turns in its window. The fall of A0 is still complete - the mark is long enough for the 1 ms time constant - and the pop-up counts 85 pulses and 2999 rpm from the last two of them.

TCRT5000 Proteus simulation: the module with its power and IR LEDs on
Figure: The module at work.
The TCRT5000 IR sensor simulation running in the Proteus workspace
Figure: The simulation in the workspace.
TCRT5000 Proteus simulation pop-up: the disc at 3000 rpm, two turns in the scope window
Figure: The disc at 3000 rpm.

Running Down and Stopping

At 4.0 s the motor is switched off and the disc runs down. The readings fall turn by turn: 2877 rpm at 4.05 s, 2167, 1473, 852 and 595 rpm at 5.05 s. The pop-up at 4.6 s shows the disc at 1200 rpm after 131 pulses, while the speed from the last two pulses still reads 1346 rpm: a turn-by-turn measurement always lags a little while the speed is changing.

TCRT5000 Proteus simulation pop-up: the disc slowing down after the motor stops
Figure: Running down.

The disc stops at 5.0 s with its black side over the sensor again: A0 settles at 4.26 V and D0 stays HIGH. For a moment the sketch still shows the last speed it measured, 595 rpm, because no new turn has come to replace it; half a second after the last turn it decides that the disc has stopped and shows 0 rpm. 135 turns in all - the disc made exactly 135 turns during the run. The A0 column of the monitor shows the same swing all the way through, 8 to 872 counts, until the last line, 872 to 872: only black.

TCRT5000 Proteus simulation pop-up: the disc stopped with its black side over the sensor
Figure: Stopped over black.

The Graphs, the Event Log and the Check Page

The Graphs page plots A0, D0, the reflectivity under the sensor and the disc's speed - the pulses crowd together as the disc speeds up and spread out as it slows. The Event log notes the power-on and the first pulse. The Check page sums up the run: the supply at 5.00 V and about 7.5 mA; the distance of 3.0 mm, 96 % of the peak signal and well inside the datasheet's 0.2 - 15 mm; the threshold with A0 steady at 4.26 V over black and D0 HIGH; 135 falling edges on D0; and a reminder of the 1 ms time constant on A0.

TCRT5000 Proteus simulation graphs: A0, D0, the reflectivity and the disc speed
Figure: The Graphs page.
TCRT5000 Proteus simulation Event log: the power-on and the first pulse
Figure: The Event log.
TCRT5000 Proteus simulation Check page after the demo run
Figure: The Check page.

The Arduino's built-in serial monitor prints a line every 250 ms: the time, the speed, the number of turns and the lowest and highest A0 reading since the last line - so the run-up, the two steady speeds and the run-down can be read back line by line.

Arduino UNO V4.0 serial monitor in the TCRT5000 Proteus simulation: the rpm, the turns and the A0 swing
Figure: The Arduino's monitor.

Setting the Trimmer

The trimmer is the most important adjustment on the module. Put the sensor over your white surface and note A0, then over the black one; set the threshold half-way between. In the simulation THRESHOLD does the same job in percent of VCC: at 50 % the threshold is 2.50 V, in the middle of the demo's 0.04 to 4.26 V swing. Move it to 90 % (4.50 V) and D0 stays LOW even over the black disc at 4.26 V; move it to 1 % and it never goes LOW at all - the check page tells you when the threshold is outside the swing.

Line Followers and Counters

The same module drives a line-following robot: two or more sensors look at the floor, and D0 is HIGH over the black line and LOW over the white floor, so the robot steers towards the sensor that sees the line. As an object counter it looks across a conveyor or a chute, and D0 drops each time something passes close by. For several sensors in a row there are ready-made line-tracker boards with five of them - the next library in this series.

Try It Yourself

  • Click U1 while the simulation runs and use the chips: White paper, Black tape and Nothing put a steady surface under the sensor.
  • Set DISTANCE to 12: the white mark still pulls A0 below the threshold, but not as far.
  • Set DISTANCE to 25: the signal is too weak and D0 stays HIGH.
  • Set THRESHOLD to 95: D0 stays LOW even over black - the trimmer turned too far.
  • Set PROFILE to STEADY with REFLECT 0.3 and turn THRESHOLD until the D0 LED just changes.

Ideas to Extend the Demo

  • Put two marks on the disc and divide the speed by two - or use the time between the marks to measure the speed twice per turn.
  • Count products on a conveyor and show the rate per minute.
  • Build a two-sensor line follower with two DC motors.

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 TCRT5000

  • Ambient light: sunlight and incandescent lamps contain infrared - shade the sensor and set the trimmer under the real light.
  • Surfaces: matt white paper and matt black tape give the clearest difference; glossy surfaces reflect away at an angle.
  • Height: mount it 2 to 5 mm from the surface for the strongest signal.
  • Debounce: a slow edge can make the comparator chatter - ignore edges that come too soon, as the demo does.
  • 3.3 V: the module works at 3.3 V too, with a weaker LED and a shorter range.

Troubleshooting

  • D0 never changes: the threshold is outside the A0 swing - turn the trimmer between the two A0 levels.
  • D0 is LOW all the time: the surface is too close or too bright for the threshold.
  • Counts are missed at high speed: the mark is too short for A0's 1 ms time constant - widen the mark.
  • Double counts: comparator chatter - debounce in software.
  • The part is not simulated: TEPTCRT5000.DLL is missing from MODELS and from the project folder.

Limitations of the Simulation

  • The distance curve follows the TCRT5000 datasheet and the circuit follows the common module's schematic; the board is our own drawing.
  • Our own figures: 1.2 mA at the peak on white, 5 uA of ambient light, a comparator without hysteresis, and the DEMO disc with its speeds.
  • Not modelled: sunlight and lamps, glossy surfaces, the sensor's angle and temperature.
  • Arduino is a name of Arduino; this library is not made or endorsed by Arduino, Labcenter or the maker of the TCRT5000.
  • Tested in Proteus 8.5 in November 2026 (the demo as shipped). Proteus 7 is not supported.

So, that was all about the TCRT5000 IR Sensor Library for Proteus Simulation. I hope it helps you build your robots, counters and speed sensors with confidence before you solder anything. 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