TEP DOWNLOAD CENTER

Project Files of Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F

Libraries Code Projects Simulation
tep://download-terminal gp2y0a21yk0f-sharp-tep-v1-0-e2759f2d1ce44e79b627becd88f5024f.zip ZIP archiveV1.0Verified14 downloadsFree
Sharp IR Distance Sensor Library for Proteus V1.0: the GP2Y0A21YK0F with its STATUS panel and the Advance pop-up
Proteus library · File 1 of 1

Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F

Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F comes as a ZIP archive of 10 files (1.2 MB, 2.7 MB unpacked) holding Proteus library files, simulation model DLLs, a Proteus simulation, an Arduino sketch and compiled HEX firmware.

  • LIBProteus library
  • DLLProteus model
  • DSNProteus simulation
  • INOArduino sketch
  • HEXHEX firmware

Description

Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F is the download package that goes with our tutorial Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F. On this page you can download the ZIP file (1.2 MB) and see what is inside before you save it: 10 files in 5 folders, the Proteus library files (LIB and IDX), the simulation model (DLL), a ready Proteus simulation, an Arduino sketch and the compiled HEX firmware. The tutorial explains the design; this page gets the files onto your computer and into use.

What this library is

Sharp-IR-Distance-Sensor-Library-for-Proteus-v1.0.zip with the Sharp GP2Y0A21YK0F IR distance sensor (10 to 80 cm, analog output), Simple and Advance (TEPSHARPIR.LIB and TEPSHARPIR.DLL), our Arduino UNO V4.0 library with its built-in serial monitor (ArduinoV4TEP.LIB and TEPARDUINO.DLL), the two-UNO simulation with its HEX file, the demo sketch and a README.

This is version 1.0; older or newer releases, when they exist, are listed in the Development tab.

What is inside the ZIP file

  • ArduinoV4TEP.LIB – Proteus library, 201.9 KB
  • TEPSHARPIR.LIB – Proteus library, 62.6 KB
  • TEPARDUINO.DLL – Simulation model, 883.5 KB
  • TEPSHARPIR.DLL – Simulation model, 325 KB
  • GP2Y0A21YK0F-IR-Distance-ArduinoUnoV4.pdsprj – Proteus simulation, 23.9 KB
  • GP2Y0A21_Distance_Demo.ino – Arduino sketch, 3.5 KB
  • and 4 more, all listed in the File Structure tab

The archive unpacks to 2.7 MB and carries its own README (README.txt), shown in the README tab above.

How to download

Use the download panel at the top of this page: after the counter (30 seconds for guests, 10 for members) the black button unlocks and the ZIP file comes straight from our content network. If the browser opens it instead of saving, use Save as; extract the whole archive before using anything inside it.

How to install

  • Step 1: Extract the ZIP file with Windows (Extract All), 7-Zip or WinRAR, keeping its folders.
  • Step 2: Close Proteus and copy ArduinoV4TEP.LIB and TEPSHARPIR.LIB into its LIBRARY folder (Proteus 8: C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY).
  • Step 3: Copy TEPARDUINO.DLL and TEPSHARPIR.DLL into the MODELS folder next to it, so the part simulates.
  • Step 4: Start Proteus, press P and search for "ArduinoV4TEP"; place and wire it as in the tutorial.
  • Step 5: Open GP2Y0A21_Distance_Demo.ino in the Arduino IDE, pick board and port and Verify (Export Compiled Binary gives the HEX).
  • Step 6: In Proteus set the controller's Program File to GP2Y0A21_Distance_Demo.hex; on hardware, flash the same file.
  • Step 7: Open GP2Y0A21YK0F-IR-Distance-ArduinoUnoV4.pdsprj in Proteus and press Play.

Read the detailed guide

This page is for the files. The tutorial above explains the circuit and the code step by step and shows the working results and the simulation; read it before you build. Questions about the download or the installation go in the comments below; more Proteus downloads are listed further down this page.

Read Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F

File Structure

gp2y0a21yk0f-sharp-tep-v1-0-e2759f2d1ce44e79b627becd88f5024f.zip10 files · 5 folders · 2.7 MB unpacked
GP2Y0A21YK0F-Sharp-TEP-v1.0/10 files · 2.7 MB
Arduino Code/1 file · 3.5 KB
GP2Y0A21_Distance_Demo/1 file · 3.5 KB
INO GP2Y0A21_Distance_Demo.inoArduino sketch 3.5 KB
Proteus Library Files/2 files · 264.5 KB
LIB ArduinoV4TEP.LIBProteus library 201.9 KB
LIB TEPSHARPIR.LIBProteus library 62.6 KB
Proteus Model Files/2 files · 1.2 MB
DLL TEPARDUINO.DLLSimulation model 883.5 KB
DLL TEPSHARPIR.DLLSimulation model 325 KB
Proteus Simulation/4 files · 1.2 MB
DSN GP2Y0A21YK0F-IR-Distance-ArduinoUnoV4.pdsprjProteus simulation 23.9 KB
HEX GP2Y0A21_Distance_Demo.hexCompiled HEX file 19.6 KB
DLL TEPARDUINO.DLLSimulation model 883.5 KB
DLL TEPSHARPIR.DLLSimulation model 325 KB
TXT README.txtText file 19.8 KB

README

README.txt 339 lines
SHARP IR DISTANCE SENSOR LIBRARY FOR PROTEUS - V1.0 (the Sharp GP2Y0A21YK0F, 10 to 80 cm)
Designed by The Engineering Projects
www.TheEngineeringProjects.com

IMPORTANT LINKS
Article (read it first - pictures, step by step, every feature explained):
  https://www.theengineeringprojects.com/2026/10/sharp-ir-distance-sensor-library-for-proteus-v1-0.html
Report a bug or suggest a feature (our forum):
  https://www.theengineeringprojects.com/forum/category/sharp-ir-distance-proteus-library
The demo runs on our Arduino UNO V4.0 (included) - working LEDs, RESET and a
built-in serial monitor, no Virtual Terminal to wire - its own article:
  https://www.theengineeringprojects.com/2026/10/arduino-uno-library-for-proteus-v40.html
The built-in monitor is our TEP Serial Monitor Advance - its own article:
  https://www.theengineeringprojects.com/2026/10/serial-monitor-advance-proteus-library.html
Support us (the libraries are free):
  https://www.theengineeringprojects.com/donate

FILE STRUCTURE
GP2Y0A21YK0F-Sharp-TEP-v1.0/
|-- Proteus Library Files/
|   |-- ArduinoV4TEP.LIB                              201.9 KB   TEP Arduino boards V4.0 (UNO), to LIBRARY
|   |-- TEPSHARPIR.LIB                                 62.6 KB   the Sharp GP2Y0A21YK0F, to LIBRARY
|-- Proteus Model Files/
|   |-- TEPARDUINO.DLL                                883.5 KB   the Arduino board model, to MODELS
|   |-- TEPSHARPIR.DLL                                325.0 KB   the GP2Y0A21YK0F model, to MODELS
|-- Proteus Simulation/
|   |-- GP2Y0A21_Distance_Demo.hex                     19.6 KB   both UNOs (demo sketch V1.0)
|   |-- GP2Y0A21YK0F-IR-Distance-ArduinoUnoV4.pdsprj   23.9 KB   demo: 2 UNOs, 2 sensors
|   |-- TEPARDUINO.DLL                                883.5 KB   copy of the board model
|   |-- TEPSHARPIR.DLL                                325.0 KB   copy of the model
|-- Arduino Code/
|   |-- GP2Y0A21_Distance_Demo/GP2Y0A21_Distance_Demo.ino    3.5 KB   the demo sketch (source of the .hex)
|-- README.txt                                        ~20.8 KB   this file
Total: 2.68 MB (unzipped). The C++ source code of the model is not included.

WHAT IS IT?
A simulation model of the Sharp GP2Y0A21YK0F infrared distance sensor: an IR
LED and a position-sensitive detector (PSD) that measure the distance to an
object from 10 to 80 cm by triangulation, with an analog output, VO.
Our own model, not a part that shows a number:
  * The output curve of the datasheet (typical, white paper with 90 %
    reflectance, VCC 5 V): 0.4 V at 80 cm and 1.9 V more at 10 cm (2.3 V) -
    its two specified points - and the graph's shape between them (1.3 V at
    20 cm, 0.92 V at 30 cm, 0.6 V at 50 cm); the peak of about 3.15 V near
    6 cm and the fall below it; past 80 cm a slow tail to about 0.27 V with
    nothing in front (the datasheet stops at 80 cm: the model's estimate).
  * The measuring cycle: one measurement every 38.3 ms (property CYCLE), its
    result on VO 5 ms after the cycle ends (the datasheet's maximum), so VO
    is a staircase that changes about 26 times a second; VO is 0 V until the
    first result is out, 38.3 + 5 ms after power-on.
  * The noise of each measurement (property NOISE, 6 mV RMS by default): the
    same value for the whole cycle - reading A0 again inside one cycle gives
    the same number.
  * The supply: 30 mA average from VCC (the datasheet's typical), 4.5 to
    5.5 V; a note below 4.5 V or above 5.5 V and above the absolute maximum
    of 7 V. VO is driven through 100 ohm (the model's own value).
  * The object in front: its distance (property DISTANCE; 0 = nothing), the
    panel's - / + (5 cm a click) and presets (3, 10, 20, 30, 50, 80 cm and
    NONE), and three motions: SWEEP 10-80 (10 to 80 cm and back in 12 s),
    APPROACH (from 80 cm to 3 cm in 10 s, slower as it comes close) and HAND
    (a hand comes in to 15 cm for 1.8 s and goes again).
  * The classic GP2Y0A21YK0F trap, caught and explained: below about 6 cm VO
    falls again, so an object at 3 cm (2.05 V) gives the same VO as one at
    11.5 cm - a sketch reads it as a valid distance. The panel turns red and
    shows what VO "looks like". Notes for an object closer than 10 cm,
    beyond 80 cm, nothing in front and a supply out of range.
The sensor is drawn at about two and a half times its real size, seen from
the front: the black body with the emitter's and the detector's lens
housings, the two mounting ears, the JST cable (red VCC, black GND, yellow
VO) with its plug on the left. ON the body, as TEP additions: the SIMPLE /
ADVANCE badge, the PWR and IR (blinks with the measurements) LEDs and the
panel button. The LEDs, the badge, the button and the panels are TEP
additions; the real sensor has none of them.

TWO DEVICES IN ONE LIBRARY (search "GP2Y0A21" or "Sharp" in Pick Devices):
  Simple    GP2Y0A21TEP      "Sharp GP2Y0A21YK0F IR Distance Sensor V1.0 -
                             Simple"
  Advance   GP2Y0A21ADVTEP   (the same, "- Advance")
            (pins VCC GND VO on the plug, on the left; category Sensors >
            Distance)
  Simple    On-Sheet Panel: the STATUS panel under the sensor - the banner
            (VO ... V = ... cm - THE OBJECT AT ... cm (IN RANGE) / TOO CLOSE in
            red / a motion or out of range in amber), DISTANCE - / + with a
            ruler (the beam and the object on 0 to 100 cm), seven presets,
            three motions, ten readouts and the last 4 events. The red X
            closes the panel, PANEL: ON / OFF on the body opens it.
  Advance   Pop-Up Panel: only the sensor on the schematic; at Run a TEP
            pop-up window opens - the look of the TEP Serial Monitor. Tabs
            Sensor, Event log and Tests; gear and ? icons for Settings and
            Help; the palette icon switches the theme:
              Sensor     the presets on the toolbar; THE OBJECT IN FRONT
                         (-5 / -1 / +1 / +5 cm, SWEEP 10-80, APPROACH, HAND, a
                         side view); THE OUTPUT (VO now, what it means, the
                         object, the measurements); THE CURVE (VO against the
                         distance with the object's point); VO OVER THE LAST
                         1.5 s (the steps of the measuring cycle); THE LAST
                         MEASUREMENTS
              Event log  power, the measurements, the object, notes, warnings;
                         filters All / Measurements / The object / Warnings,
                         Pause, Clear
              Tests      Output & curve, Timing, Supply & wiring (THE TEST
                         TOOLS)
              Settings   theme, text size, open at Run, window size
              Help       report a bug, suggest a feature, article, updates,
                         donate, forum; Copy diagnostics for a bug report
            The OPEN PANEL button on the body opens the window again.
Both devices use one model, TEPSHARPIR.DLL.

TEST STATUS
V1.0: verified in Proteus 8.5 on 17 Oct 2026 (the demo project as shipped:
two Arduino UNO V4.0 boards with their built-in monitors; node 1 with the
Simple sensor and the object at 20 cm, node 2 with the Advance sensor and the
object at 50 cm). What the runs showed:
  * Both UNOs read their sensor twice a second: node 2 "#1  A0 122  0.60 V
    50.3 cm", node 1 "A0 266  1.30 V  19.9 cm".
  * U2's pop-up and monitor: 20 cm - "A0 266  1.30 V  19.9 cm" on the next
    line; RAW - "RAW: 267 267 ... 267 265 265 ..." (fourteen times 267, then
    six times 265: VO changes once per measuring cycle); 3 cm - "A0 420
    2.05 V  11.6 cm" while the pop-up shows TOO CLOSE; NONE - "A0 56  0.27 V
    nothing in range (beyond 80 cm)"; SWEEP 10-80 - from 17.8 to 77.4 cm and
    back to 10.1 cm; APPROACH - 21.5, 17.5, 14.8, 11.9, 9.6, 7.5 and 7.0 cm,
    then 7.9, 9.5, 11.1, 11.5 and 11.6 cm while the object comes on to 3 cm;
    the three tools and the Event log.
  * Node 1 with the real mouse (3 wheel steps on U1): + twice - "A0 188
    0.92 V  30.1 cm"; HAND - four lines of "15.0 cm", then 30 cm again; 3 cm -
    the panel's banner in red, VO MEANS 11.5 cm; 20 cm; U1's red X and PANEL.
  * 81.7 s of simulation took 156 s - about 0.5 x real time with the pop-up
    and both monitors open.
  Plus automatic checks on a PC, 0 failed: 98 on the model (the curve against
  the datasheet's two points, the demo's formula within 1.2 % from 10 to 80
  cm, the far side and the trap, the measuring cycle and VO's timing, the
  noise, power on / off and VCC, the controls, the motions, the notes) and 6
  on the pop-up; the demo project read back from disk (57 checks: devices,
  pins, wires, labels; no wire through a part, no wire crossing).

INSTALLATION (about 2 minutes)
1. Close Proteus. Extract the WHOLE ZIP to a normal folder (e.g. Desktop).
2. Copy everything in "Proteus Library Files" (TEPSHARPIR.LIB with the two
   parts, and our Arduino library V4.0, ArduinoV4TEP.LIB, with the ARDUINO
   UNO V4.0 used by the demo) to the LIBRARY folder of Proteus, for example:
     C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY
   (on some PCs: C:\ProgramData\Labcenter Electronics\Proteus 8 Professional\
   LIBRARY - use the folder that already holds Proteus's own .LIB files).
3. Copy TEPSHARPIR.DLL and TEPARDUINO.DLL from "Proteus Model Files" to the
   MODELS folder (...\Proteus 8 Professional\MODELS).
   ArduinoV4TEP.LIB and TEPARDUINO.DLL are the files of our Arduino Library
   V4.0 - if you have it, they are the same.
4. Delete TEPSHARPIR.IDX from the LIBRARY folder if it is there (Proteus
   makes a new index).
5. Start Proteus. In Pick Devices (P) search "GP2Y0A21" (or "Sharp").

RUN THE DEMO
"Proteus Simulation\GP2Y0A21YK0F-IR-Distance-ArduinoUnoV4.pdsprj" - keep the
.hex file and the two DLLs beside the project.
  ARD1: Arduino UNO V4.0 + U1 = a GP2Y0A21YK0F (Simple), the object at 20 cm.
  ARD2: Arduino UNO V4.0 + U2 = a GP2Y0A21YK0F (Advance), the object at 50 cm.
  Both UNOs run GP2Y0A21_Distance_Demo.hex (no library) and each has its
  serial monitor built in ("TEP Arduino UNO - ARD1" / "- ARD2").
  1. Press Run. Both UNOs' monitor windows open (9600 baud) and so does the
     pop-up of U2 (move it aside - it opens over the schematic).
  2. Twice a second each UNO prints its reading of A0, the voltage and the
     distance from the demo's formula.
  3. Move the object on U1's STATUS panel or in U2's pop-up (DISTANCE - / +,
     the presets): the reading follows within a measurement or two. SWEEP
     10-80 and APPROACH move it; HAND passes a hand in front.
  4. Try 3 cm or APPROACH: below about 6 cm VO falls again and the sketch
     reads a larger distance - the classic trap of this sensor.
  5. RAW prints 20 readings 5 ms apart: the same value until the next
     measurement.
  6. U1: close its panel with the red X, open it with PANEL on the body.
     U2 (Advance): Sensor, Event log, and Tests - Output & curve, Timing,
     Supply & wiring.
Closed a monitor window? Click the UNO's USB port.

WIRING (the same in Proteus and on a real board)
  Sensor   Arduino UNO
  VCC      5V
  GND      GND
  VO       A0 (any analog input)
The cable of the JST connector: pin 1 VO, pin 2 GND, pin 3 VCC - the colours
differ between sellers (VO is often yellow or white), so go by the names.
In the sketch (no library):
  int a = analogRead(A0);                // once per measuring cycle
  float v = a * 5.0 / 1024.0;            // the 5 V reference
  float cm = 27.19 * pow(v, -1.189);     // 10 to 80 cm
Read A0 once per measuring cycle (40 ms) and take the median of a few
readings; below 0.4 V there is nothing within 80 cm.
The serial monitor needs no wires: it is built into the Arduino UNO V4.0.
VO reaches its UNO through net labels - VO_1 (node 1), VO_2 (node 2): the
same name = connected. VCC and GND are Proteus power terminals.
REAL HARDWARE:
 * Put a 10 uF (or larger) capacitor across VCC and GND close to the sensor:
   the IR LED's current pulses put spikes on the supply and on VO.
 * Mount it so nothing can come closer than 10 cm (the trap above).
 * The sensor needs 4.5 to 5.5 V; on a 3.3 V board power it from 5 V - VO
   stays below about 3.2 V, safe for a 3.3 V analog input.
 * Glass, mirrors and very dark or shiny objects can give wrong readings;
   strong sunlight can blind it.

THE TEST TOOLS (Advance, Tests tab) - what they really measure
Every tool reads the model during the running simulation; each shows one
"Good for:" line and, where it judges, a verdict per row (green = fine, amber
= check, red = wrong).
  Output & curve
                Good for: a distance that is wrong, jumps, or grows when the
                object comes closer; checking a conversion formula. The
                object and its range, VO now and its analogRead, what VO
                means on the curve and with the demo's formula; the curve
                from 2 to 100 cm with the formula's error at each point.
  Timing        Good for: readings that repeat, readings that lag a moving
                object, a wrong first reading after power-on. The measuring
                cycle, the power-on and the first result, the measurements so
                far, how often a fast loop reads the same value; the last
                measurements with their times and steps.
  Supply & wiring
                Good for: a sensor that reads 0, a VO lower than it should
                be, a noisy supply, the connector's pinout. VCC against 4.5 -
                5.5 V, the current, the load on VO (the model's VO against the
                pin's), the JST pinout and the Arduino pins.

THE DEMO SKETCH ON THE SERIAL MONITOR (GP2Y0A21_Distance_Demo V1.0)
  RUN        the readings go on (twice a second)
  STOP       no more readings
  RAW        20 analogRead values 5 ms apart
  HELP       the command list
Commands are not case-sensitive; type them in the UNO's built-in monitor and
press Enter.

EXPECTED MONITOR OUTPUT (the start)
  TEP GP2Y0A21YK0F IR distance sensor - demo
  VO on A0: distance = 27.19 x VO^-1.189 cm (10 - 80 cm)
  Commands: RUN | STOP | RAW | HELP
  #1  A0 122  0.60 V  50.3 cm
  #2  A0 124  0.61 V  49.4 cm
  #3  A0 123  0.60 V  49.9 cm
(That is node 2, the object at 50 cm; node 1, at 20 cm, prints "A0 266  1.30 V
19.9 cm". The last digit moves a little: the noise of each measurement -
property NOISE. Below 0.35 V the sketch prints "nothing in range (beyond 80
cm)".)

PROPERTIES (double-click the part > Edit Properties)
  DISTANCE     the object's distance at the start in cm (default 20; 0 =
               nothing in front)
  CYCLE        the measuring cycle in ms (default 38.3; the datasheet:
               38.3 +- 9.6 ms)
  NOISE        the output noise in mV RMS (default 6; 0 = none)
  PANEL        Simple only: the STATUS panel at the start, OPEN or CLOSED
Every run starts again from the properties, and the sensor from power-on.
The demo's UNOs (ARDUINO UNO V4.0): PROGRAM GP2Y0A21_Distance_Demo.hex,
MONITOR YES (the built-in monitor), BAUD 9600, AUTOOPEN YES, BOOTLOADER YES.

LINKS.INI (OPTIONAL)
The Help page cards of the Advance device open web pages. To point them
somewhere else without a new DLL, put a text file named links.ini next to
TEPSHARPIR.DLL with lines KEY=URL, for example:
  ARTICLE=https://www.theengineeringprojects.com/...
Keys: WEBSITE, FORUM, BUG_REPORT, FEATURE_REQUEST, ARTICLE, USER_GUIDE,
UPDATE_CHECK, DONATE. Only http:// and https:// links are used; lines starting
with # are comments.

TROUBLESHOOTING
* The reading is 0 (A0 0, 0.00 V): no power on VCC / GND, VO not on the
  analog input - the PWR LED is off. In the first 43 ms after power-on VO is
  0 V too.
* The distance grows when the object comes closer: it is closer than about
  6 cm - VO falls again below the peak; keep objects 10 cm or more away.
* The reading jumps or is noisy: take the median of a few readings, one per
  measuring cycle; on real hardware add the 10 uF capacitor.
* "nothing in range (beyond 80 cm)": VO is below 0.35 V - nothing within
  about 90 cm, or the object is too far for this sensor.
* VO lower than the curve: something loads VO (Tests > Supply & wiring shows
  the current into it).
* The parts are not simulated: TEPSHARPIR.DLL is missing from MODELS and from
  the project folder. No UNO / no monitor window: TEPARDUINO.DLL is missing,
  or click the UNO's USB port.
* Advance: the pop-up does not appear - click OPEN PANEL on the body, or turn
  "Open the panel at Run" on its Settings page back on.

BUG REPORTS AND FEATURE REQUESTS
Please post them in our forum with a screenshot, the Serial Monitor text, the
simulation log and (Advance) the Copy diagnostics text:
  https://www.theengineeringprojects.com/forum/category/sharp-ir-distance-proteus-library

SUPPORT US
This library is free. If it saves you time, please support our work:
  https://www.theengineeringprojects.com/donate

WEBSITE
  https://www.theengineeringprojects.com/

LICENCES AND THIRD-PARTY NOTES
* The GP2Y0A21YK0F model (TEPSHARPIR.DLL), the symbols and artwork and the
  Arduino Library V4.0 (ArduinoV4TEP.LIB / TEPARDUINO.DLL, with its built-in
  TEP Serial Monitor Advance) are made by The Engineering Projects. The model
  is an independent implementation written from the GP2Y0A21YK0F datasheet.
  The model uses only standard Windows libraries; no Visual C++
  redistributable is needed.
  The C++ source code is not included.
* Arduino UNO V4.0 (ArduinoV4TEP.LIB / TEPARDUINO.DLL, our Arduino Library
  V4.0 - its microcontroller is Proteus's own AVR model): The Engineering
  Projects, https://www.theengineeringprojects.com/2026/10/arduino-uno-library-for-proteus-v40.html
* The demo sketch needs no library. The .hex file is built from the demo
  sketch and the Arduino AVR core 1.8.6, which includes LGPL-licensed code;
  its source code is available at
  https://github.com/arduino/ArduinoCore-avr/tree/1.8.6
  The demo sketch's source is in "Arduino Code", so the .hex can be rebuilt
  with other versions of the core (REBUILDING THE FIRMWARE).
* Proteus is a product of Labcenter Electronics and is not included. Arduino is
  a trademark of Arduino SA. The GP2Y0A21YK0F is a product of Sharp (Sharp
  Socle Technology). This library is not made or endorsed by Sharp or
  Labcenter.

REBUILDING THE FIRMWARE (OPTIONAL)
The HEX file is supplied; Arduino IDE is not needed to run the demo. To edit the
sketch, open Arduino Code\GP2Y0A21_Distance_Demo\GP2Y0A21_Distance_Demo.ino in
the Arduino IDE, select Arduino Uno and use Sketch > Export Compiled Binary.
Replace the simulation's .hex with the exported HEX.
The sketch needs 7,142 bytes of flash and 270 bytes of RAM.

MODEL SCOPE AND LIMITS
Modelled: the output curve (typical, white paper 90 %), the near-side fall
below 6 cm, the tail past 80 cm, the measuring cycle and the output's timing,
0 V until the first result, the noise of each measurement, the supply
current and its limits, the object's distance and its motions.
How the part works with the circuit: VCC and GND power the sensor (30 mA);
VO is an analog source behind 100 ohm, so an analog input reads it directly;
the model lands a simulation time point on each change of VO.
Not modelled: the object's colour and material (the datasheet's grey and white
curves are close; glass, mirrors and black surfaces are not), its size and
angle, sunlight and other IR, the supply spikes of the IR LED's pulses (the
current is the average), the part-to-part spread (the datasheet's 0.25 to
0.55 V at 80 cm), temperature. The near side below 6 cm and the tail past
80 cm follow the datasheet's graph only roughly.

VERSION
TEP Sharp GP2Y0A21YK0F library V1.0 (Oct 2026). Devices GP2Y0A21TEP /
GP2Y0A21ADVTEP (TEPSHARPIR.LIB / TEPSHARPIR.DLL). Demo sketch
GP2Y0A21_Distance_Demo V1.0 (no library). Demo board: ARDUINO UNO V4.0 (TEP
Arduino Library V4.0) with its built-in serial monitor.
Advertisement

Development1 release

  1. V1.0Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0Fthis page

    V1.0 is the only release in the Download Center so far. When a newer version is published, it appears above with its own download page.

Installation8 steps

From the download to a working project, in order. The steps follow what the package contains.

You will need

  • Proteus Design SuiteProteus 8 or newer (Labcenter), on Windows
  • Arduino IDE1.8 or 2.x, with the board of the tutorial chosen under Tools → Board
  • Any archive toolWindows, macOS and Linux extract ZIP files on their own

Steps

  1. 1

    Extract the archive

    Right-click gp2y0a21yk0f-sharp-tep-v1-0-e2759f2d1ce44e79b627becd88f5024f.zip and choose Extract All (or open it with 7-Zip or WinRAR) into a folder you can find again. Keep its folder structure (GP2Y0A21YK0F-Sharp-TEP-v1.0) as it is.

  2. 2

    Copy the library files into Proteus

    Move ArduinoV4TEP.LIB and TEPSHARPIR.LIB and the files into the LIBRARY folder of your Proteus installation: C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY for Proteus 8, or the matching Proteus 7 folder. Older versions keep it under ProgramData\Labcenter Electronics. If Proteus is open, close it first.

  3. 3

    Add the simulation model

    Copy TEPARDUINO.DLL and TEPSHARPIR.DLL into the MODELS folder next to LIBRARY, so the component can run, not only be drawn.

  4. 4

    Restart Proteus and place the component

    Start Proteus, open a schematic, press P (Pick Devices) and search for the component by the name used in the tutorial. It appears with its pins ready to wire.

  5. 5

    Open the sketch in the Arduino IDE

    Open GP2Y0A21_Distance_Demo.ino, select your board and port under Tools, then Verify. Sketch → Export Compiled Binary writes the HEX file a simulation needs.

  6. 6

    Load the HEX file

    In Proteus double-click the microcontroller, set Program File to GP2Y0A21_Distance_Demo.hex and run the simulation. For real hardware, flash the same file with your programmer.

  7. 7

    Open the example simulation

    Open GP2Y0A21YK0F-IR-Distance-ArduinoUnoV4.pdsprj in Proteus to see the wiring exactly as in the tutorial. Check the controller's Program File path, then press Play.

  8. 8

    Follow the tutorial

    Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F explains every connection and setting in order; keep it open beside the files while you build.

How to add a library in Proteus 8

FAQs9 questionsContact TEP

How do I download Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F?

Wait for the 30-second guest countdown on this page, then press the download button; the file comes straight from our storage. Members who are logged in skip the wait. If the browser opens the file instead of saving it, use its Save as option. The download link is made for you when the countdown ends and works for 15 minutes; a saved or shared link stops working, so share this page instead.

What is inside the archive?

Sharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F comes as a ZIP archive of 10 files (1.2 MB, 2.7 MB unpacked) holding Proteus library files, simulation model DLLs, a Proteus simulation, an Arduino sketch and compiled HEX firmware. Open the File Structure tab for the full list of 10 files.

What should I do if the download does not start?

Check the browser's download list first; an ad blocker or a company firewall can also hold it back, so try another browser or network. If the file arrives incomplete, download it again. For an installation problem, read the Install tab or tell us in the comments with your software version and the exact error message.

Is this file free?

Yes. Every file in the TEP Download Center is free for learning, personal and student projects. If you share it, link back to this page or the tutorial so others find the latest version.

How do I check that the file arrived complete?

Compare its SHA-256 with the one on this page, 3faf2ee384464b1f319d20cb75d0d8caf1b4be5eac814558757ad0dd7b37f486. In PowerShell run Get-FileHash "gp2y0a21yk0f-sharp-tep-v1-0-e2759f2d1ce44e79b627becd88f5024f.zip"; on macOS or Linux run shasum -a 256 "gp2y0a21yk0f-sharp-tep-v1-0-e2759f2d1ce44e79b627becd88f5024f.zip". The same value means the file is exactly the one in our storage; a different one means the download broke off, so download it again.

Do I need WinRAR to open the ZIP file?

No. Windows, macOS and Linux open ZIP archives on their own (Extract All, or double-click). WinRAR and 7-Zip work too. Extract the whole archive before using the files.

Where do I put the LIB and IDX files?

Both files go into the LIBRARY folder of your Proteus installation (Proteus 8: C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY; Proteus 7 has the same folder under its own name). Restart Proteus afterwards and search for the component with P.

Which Proteus version does the library need?

The tutorial names the Proteus version the library was made and tested with. Most TEP libraries work in Proteus 7 and Proteus 8; if the component does not appear after a restart, check that both the LIB and the IDX file were copied and that Proteus was fully closed while copying.

How do I get the HEX file into the simulation?

Compile the sketch in the Arduino IDE (Sketch → Export Compiled Binary gives you the HEX next to the sketch), then in Proteus double-click the board, set Program File to that HEX and run.

preparing · gp2y0a21yk0f-sharp-tep-v1-0-e2759f2d1ce44e79b627becd88f5024f.zip
Rating
Your download will be ready shortly
Preparing your download…

Members skip the wait. Log in or join TEP.

  • 14Total downloads
  • 4%Popularity
  • ProteusCategory
  • 0Comments
  • ssyedzainnasirUploaded by
  • 16 Oct 2026Uploaded at
Last 14 days10 downloads
SHA-256 3faf2ee384464b1f319d20cb75d0d8caf1b4be5eac814558757ad0dd7b37f486
DocumentationSharp IR Distance Sensor Library for Proteus V1.0: GP2Y0A21YK0F
Need help with this file? Bug report Ask a question Download problemsGet updates
Advertisement

Comments

0

Join the conversation

Start the conversationAsk a question or share how you used this download.