How to add And Simulate Ultrasonic Sensor in Proteus ?

How to Add And Simulate Ultrasonic Sensor Library in Proteus ?

The Ultrasonic Sensor also called “Ping Sensor” is used to detect the objects in front and measure the distance between the sensor and object. In this post, I will show you how you can simulate an ultrasonic sensor in Proteus and how to use it to measure the distance. But first, let’s see how to add and simulate Ultrasonic Sensor library in Proteus.

How to add Ultrasonic Sensor Library to Proteus?

You can also watch this video for easy reference:


STEP 1: First of all download Arduino Library from the link given below:

Ultrasonic Sensor Library For Proteus

**Don’t have an Arduino library? Click here to download that library.

STEP 2: Download the file to the desktop


STEP 3: Unzip the .zip file to the desktop


STEP 4: You will obtain these three files:

 (A) 1.UltrasonicTEP.LIB


 (B) 3.UltraSonicTEP.HEX


STEP 5: Copy the first two files and paste them in:

 Go to “C:\Program Files (x86)\Labcenter Electronics\Proteus 7 Professional\LIBRARY”

                Next Copy the  “.HEX” file and paste it in:

Go to “C:\Program Files (x86)\Labcenter Electronics\Proteus 7 Professional\BIN”


STEP 6: Open proteus and click on “pick from libraries”


STEP 7: Search for “ultrasonic” in the components tab. You will see “ultrasonic sensor”.  Select it and then place it anywhere on the front panel!


STEP 8: Double-click on the sensor and then click on the “Ultrasonic sensor.HEX” as shown in the figure BELOW.






STEP 9: Select “UltraSonicTEP.HEX” file from BIN and hit enter as shown in figure.






STEP 10: Now you are good to go!  You can Start simulating Ultrasonic Sensor right away.

Check out this project on Ultrasonic Sensor:  “How to measure distance using Ultrasonic Sensor


How to simulate Ultrasonic Sensor with Arduino in Proteus?

Before going further be sure to check out ” How to add and simulate Arduino in Proteus?


PROJECT:  Measuring distance using Ultrasonic Sensor Library with Arduino Library in Proteus.


STEP 1: Connect all components as shown in the simulation figure below.

Ultrasonic Sensor With Arduino in Proteus







STEP 2:  Download this “UltraSonic ” program to your Arduino IDE:

const int echoPin = 2; // Echo Pin of Ultrasonic Sensor
const int pingPin = 3; // Trigger Pin of Ultrasonic Sensor
void setup() 
  Serial.begin(9600); // Starting Serial Communication
  pinMode(pingPin, OUTPUT); // initialising pin 3 as output
  pinMode(echoPin, INPUT); // initialising pin 2 as input

void loop()
  long duration, inches, cm;
  digitalWrite(pingPin, LOW);
  digitalWrite(pingPin, HIGH);
  digitalWrite(pingPin, LOW);

  duration = pulseIn(echoPin, HIGH); // using pulsin function to determine total time
  inches = microsecondsToInches(duration); // calling method
  cm = microsecondsToCentimeters(duration); // calling method
  Serial.print("in, ");

long microsecondsToInches(long microseconds) // method to covert microsec to inches 
 return microseconds / 74 / 2;

long microsecondsToCentimeters(long microseconds) // method to covert microsec to centimeters
   return microseconds / 29 / 2;




STEP 3: Go to preferences








STEP 4: Check “Compilation” CheckBox






STEP 5:  Click on verify (compile)






STEP 6: After compilation is complete copy the HEX file path from the bottom corner:



STEP 7: Open Proteus and double click on Arduino. Paste the file path and click ok







STEP 8: Double-click on the sensor and then click on the Ultrasonic sensor.HEX as shown in the figure.






STEP 9: Select “UltraSonicTEP.HEX” file from BIN and hit enter as shown in figure.






STEP 10: Run the simulation! Change the potentiometer’s wiper terminal position to test the distance value on the virtual terminal. As you can see in the picture below, the value of the distance gets printed on the serial monitor.


Read Similar Articles:

How To Change Frequency On PWM Pins Of Arduino UNO

How to Add Microphone library to Proteus and generate audio waveforms

How to add Arduino Library to Proteus and Simulate Arduino Projects


  1. I got proteus 8.7 SP1 pro (legal) and try to simulate, I got this error :
    mixed model PIC16EX.DLL failed to authorize – Product Key not found. [SONAR1]

    Do you know tis error, can you help me
    Thank you

  2. I haven¦t checked in here for a while because I thought it was getting boring, but the last several posts are good quality so I guess I will add you back to my daily bloglist. You deserve it my friend 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *