WAZIRI UMARU FEDERAL POLYTECHNIC,
BIRNIN KEBBI
Department of Computer Engineering
INTRODUCTION TO MICRO AND ASSEMBLY LANGUAGE
LAB MANUAL (CTE 241)
TOPIC: HOW TO ADD AND SIMULATE ULTRASONIC
SENSOR LIBRARY IN PROTEUS
BY:
Engr. Umar Yahaya
Department of CTE
Name of the Student: ALIYU NAZIRU DIGGI
Matric No: NCT/23/0021
Year/Sem/Class: 2025/2ND SEMISTER/ND 2
1
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?
STEP 1: First of all have your Proteus application on your desktop
Don’t have Proteus application on your desktop? Click here to download the
.zip file
STEP 2: Download Arduino library (ARDUINO.LIB) and Ultra Sensor Library
***Don’t have an Arduino library? Click here to download.
***Don’t have an Ultra Sensor Library? Click here to download
STEP 3: Unzip the .zip file to the desktop
STEP 4: You will obtain these three files(from the ultrasonic library):
1. UltrasonicTEP.LIB
2. UltrasonicTEP.IDX
3. UltraSonicTEP.HEX
STEP 5: Copy the first two files(1 & 2) and paste them in:
2
“C:\Program Files (x86)\Labcenter Electronics\Proteus 7
Professional\LIBRARY”
Next Copy the “.HEX” file and paste it in:
“C:\Program Files (x86)\Labcenter Electronics\Proteus 7 Professional\BIN”
STEP 6: Open Proteus and click on “pick from libraries” or use the shortcut
(p):
1. And search for ultrasonic in the tab, you will see ultrasonic sensor, select
it and paste anywhere in the panel
2. Double click on the sensor and the add the ultrasonic sensor HEX file and
add to the it as shown below
Now we are ready for stimulation
How to simulate Ultrasonic Sensor with 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.
3
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);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
duration = pulseIn(echoPin, HIGH); // using pulsin function to determine total
time
inches = microsecondsToInches(duration); // calling method
4
cm = microsecondsToCentimeters(duration); // calling method
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
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;
}
Copy the above and paste in your arduino IDE
STEP 3: Go to preferences (incase the code fail to compile)
5
Check “Compilation” CheckBox
STEP 4: Click on verify (compile)
STEP 5: After compilation is complete copy the HEX file path
6
Then open proteus and double click om Arduino and paste the file path
you copy and paste
STEP 6: 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.
7
8