Hello friends, hope you all are fine and having good health. In today's post, I am going to share an Ultrasonic Sensor Library for Proteus. A few days ago, I posted a tutorial on Arduino Library for Proteus, and today I am going to share the new Ultrasonic Sensor Library for Proteus. Using this library, you can easily interface Ultrasonic Sensors with different Microcontrollers like Arduino, PIC Microcontroller etc.
First of all, let's have a brief introduction to ultrasonic sensor. In an ultrasonic sensor, there are two nodes available, one is the transmitter while the other is the receiver. The transmitter sends an ultrasonic wave and this wave strikes any hindrance present in front of it and then bounces back. This bounced ultrasonic sensor is then captured by the receiver and on the basis of the time taken by this wave to return, the sensor calculates the distance of that obstacle from that sensor.
The Ultrasonic sensor is usually used for detecting the obstacle in the path and also to find the distance between the sensor and the obstacle. The ultrasonic sensor normally used is HC-SR04, which we have designed in this library. Let's get started with Ultrasonic Sensor Library for Proteus, in this library we have used an extra pin on the ultrasonic sensor, which is an analog pin. The voltage on that pin is used to detect how close an object is because it's a simulation and we can't place an actual object in front of the simulated sensor. Moreover, you should also have a look at this Home automation Project using XBee & Arduino, I have used this ultrasonic sensor in that project.
I hope you are going to enjoy this library. This library is designed by our team after a lot of effort, if you have any feedback to improve, please let us know. So, let's get started with Ultrasonic Sensor Library for Proteus and its interfacing with Arduino.
Note:
Note:
const int pingPin = 7; // Trigger Pin of Ultrasonic Sensor const int echoPin = 6; // Echo Pin of Ultrasonic Sensor void setup() { Serial.begin(9600); // Starting Serial Terminal } void loop() { long duration, inches, cm; pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(10); digitalWrite(pingPin, LOW); pinMode(echoPin, INPUT); duration = pulseIn(echoPin, HIGH); inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration); Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println(); delay(100); } long microsecondsToInches(long microseconds) { return microseconds / 74 / 2; } long microsecondsToCentimeters(long microseconds) { return microseconds / 29 / 2; }
That's all for today, in the coming post I am gonna share some more examples of how to use ultrasonic sensor in Proteus. Till then take care and have fun.
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w