Search This Blog

Powered by Blogger.

Translate

Home » , , » [TC] Arduino based distance sensor

[TC] Arduino based distance sensor

Here  is a simple tutorial to build a Distance sensor which will show the distance from the distance sensor HC-SR04 ( Or any other compatible devices) to the wall or obstacles in front of the sensor in CentiMeters.This project uses a HCR-SR04 distance sensor and atmega 328 or any other atmega chip which is programmed using a arduino programming kit, SO the project is based on arduino. But our final Circuit will be a standalone circuit without attached arduino programmer.Hardware Used:

HC-SR04It is a simple Ultrasonic ranging module
hc-sr04
hc-sr04
With Specifications:

power supply :5V DCquiescent current : <2mAeffectual angle: <15°ranging distance : 2cm – 500 cmAnd whose Sequence chart is

:sequence chart

sequence chart. We can send a short ultrasonic pulse at t1 , and if any obstacles is there the received ultrasonic signal is converted to an electrical signal as Echo.  If a 10μs width trigger pulse is sent to the signal pin, the Ultrasonic module will  output eight 40kHz ultrasonic signal and detect the echo back. The measured distance is proportional to the echo pulse width and can be calculated by the formula above. If no obstacle is detected, the output pin will give a 38ms high level signal. 

Arduino : Either a Arduino Board or a Arduino IC( Atmgea 328 , Atmega 128 , Atmega 8 etc ) with a programmer is used. To know more about Arduino visit the official arduino site http://arduino.cc 

16*2 LCD
2X16 LCD
 2X16 LCD


Wiring:SO If you are going to use arduino board then please connect devices as following:FOR LCD:* LCD RS pin to digital pin 12* LCD Enable pin to digital pin 11* LCD D4 pin to digital pin 5* LCD D5 pin to digital pin 4* LCD D6 pin to digital pin 3* LCD D7 pin to digital pin 2* LCD R/W pin to ground* 10Komhs Variable resistor   with two ends to +5v and ground and the middle wipper ti LCD pin VO.If you also have back light in your LCD and  want to enable it:* LCD A to +5v , LCD K to Ground.And LCD VSS to Ground , LCD VDD to +5v.FOR HC-SR04:* VCC to +5v , Gnd to Groung* “Trig” Pin to Digital pin 7* “Echo” Pin to Digital pin 8 And if You are not using Arduino Board instead using a Arduino IC after programming it then use the following schematic: 

distance meter  

Software:

Here is a simple version of the software:

#define trigPin 7
 #define echoPin 8
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
int timetaken, dist;
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
timetaken = pulseIn(echoPin, HIGH);
dist = (timetaken/2) * 0.034049 ;
if (dist >= 300 || dist <= 0){
Serial.println(“Out Of Range”);
}
else {
Serial.println(“Distance in CM: “);
Serial.print(dist);
}
delay(500);
}


Theory:

Here , we are going to calculate the distance of the sensor and any object in front of it. At t1 we send the trigger signal , and at t2 we get the echo.so dt = t2-t1And as dt is the time for the sound taken to reach to the object and return back;The exact time taken by the sound to reach the object is : dt/2Now , Normal speed of sound is: 340.29 m / s And converting it to Centimeters per Micro Seconds gives : 0.034049 CM / microsecondsThe actual distance traveled by the sound or the distance between the sensor and the object is:(dt/2) * 0.034049
Which is the exact formula used in the software.


Source: http://electronicsproject.org/ 
Share this on your favourite network

0 comments:

Post a Comment

Page Rank

google pagerank

Write For Us

Submit a Guest Post

Find us on Facebook

Categories

555 Timer IC 7 segment Display 8051 Project AC Circuits Adafruit Alarms Amplifier Circuits Analog Circuits android Arduino arm processor Assembly Languange Atmel Atom Size Audio Circuits augmented reality Automotive Circuits avr Battery Circuits Bicycle Gurad bluetooth Cable TV Circuits Cambridge University Camera Technology Circuit Boards Clipping And Clamping Circuits Clocking And Timer Circuits Computing contact lens Contact Us Form Contests Controller Circuit Conversion Circuits Counter Circuits Digital Electronics diy circuits Downloads EFY EFYTimes Electronic Books Electronic Components Electronic Locks And Keys Engineering Fan Circuits Filter Circuits Fire Alarm free Frequency Fun And Game Circuits future Google Hack n Mod Ham Radio Circuits heart rate monitoring High Voltage Circuits Home Circuits IC Guide ieee Industrial Circuits Infrared Instructables Inventions ipad lcd Led Circuits Light Related Lighting Circuits Medical Circuits Meter Clocks Microcontrollers Microprocessors Mini Projects modules Movie maker NatGeo Navigation Notice Optical Fiber PC Circuits PCB Boards Physics pnp transistor Power Supplies Printing Projects Programmer Project Ideas Projectors Protection circuits Proximity Detectors Radar Radio Circuits Radio Transmitters Raspberry Raspberry Pie Remote Circuits Retis Lab RFID Robot Cars Robotics Science Science Alert Security And Safety Sensor Circuits Servo Motors Smallest Smartwatches sms Software solar cell sound application Spectram Switch Technology News Telephone Related Television Related Test And Measurement Circuits Thermal Projects Tone generator circuits Touch Screen Tutorials Wearables Wi-Fi Wireless
Like us on Facebook
Follow us on Twitter
Recommend us on Google Plus
Subscribe me on RSS