Ultrasonic Range Finder with Arduino

I recently got a Maxbotix LV-EZ4 Ultrasonic Range Finder to try understand how to use it with my little Arduino. Having a ultrasonic range finder can be very useful in many different projects, as it can detect objects, I can use it to make alarm systems (cars usually use this kind of sensor), Obstacle-Avoiding Robot and many other things that you may have in mind. It works better outdoors then the IR sensor, but the only thing I could notice is that it doen’t detects very well some thick carpets. Besides that, it’s a great sensor. From the datasheet we can read that it sonar range information from 6-inches out to 254-inches (15.24 cm – 6.452m).

ultrasonic range finder

Maxbotix Features:

  • 42kHz Ultrasonic sensor
  • Operates from 2.5-5.5V
  • Low 2mA supply current
  • 20Hz reading rate
  • RS232 Serial Output – 9600bps
  • Analog Output – 10mV/inch
  • PWM Output – 147uS/inch
  • Small, light weight module

Docs:

How the Sonar works:
It basically sends a high frequency wave in one direction, the wave hits a object that reflects the wave. When the wave gets back to the sensor, it calculates the distance depending on the time it takes to go and back. More information can be checked at Wikipedia.

Working with Arduino:

I think the easiest way to work with the sensor is using the Analog Output Mode, where you just need to give the sensor some juice connecting with the 5V and Ground, and the Analog Output on any Analog-Digital Converter pin on the Arduino. Where it gives (Vcc/512) / inch where I am using 5V, so it’s 10mV/inch. But the AD from the Arduino have 1024 steps from 0-5V. So to have the information from the sensor in inches we need to make ADvalue/2 and if you want to have the information in cm, just multiply the previous value for 2.4 (1 inch = 2.4 cm).

Pics:

Video:

So here is the code:
You can download the file HERE.

Comments

  1. I just picked up a Maxsonar MB7360 and I am trying to find out how to connect it to my arduino mega256. Would you know what pins I would use to hook it up so I can try out your program? I am very very new to using the arduino and would appriciate any help you could give me

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.