Follow MaxBotix:
Ask A Question
|     Written By: Tom Bonar     |     Date Posted: 04-30-2014    |
The Arduino micro-controller is one of the most popular development boards for electronics enthusiasts. With the ability to control components such as buzzers, LED’s, servos, motors, and LCD’s, Arduinos have become the go-to selection for users that are looking to start into electronics, firmware coding, or automation. So with all these item types at your finger tips, what good is it to have control over so many components, if there are no sensors to trigger different functions in the Arduinos firmware?

The MaxBotix Inc., MaxSonar sensor line has become a very popular sensor for operation with the Arduino micro-controller. With three simple interfaces, it is easy to connect a MaxSonar to an Arduino.

In this article, I will be providing: links to components needed, wiring diagrams for all outputs, and Arduino sketch files for all compatible MaxSonar sensors. With that being said, let’s get coding!

Table of Contents


List of Materials Needed

Setting Up the Arduino

Wiring Pictures


Arduino Coding Part 1

    Useful Information
    Arduino Comments
    Code the Input & Variables

Arduino Coding Part 2

    Code Setup
    Code Section to Read Sensor

Arduino Coding Part 3

    Code Debug Section
    Code Void Loop
    Review the Code

Code Downloads

    LV-MaxSonar Code Downloads
    XL-MaxSonar Code Downloads
    HR-MaxSonar Code Downloads

Setting up the Arduino

This section assumes the Arduino Ultimate Starter Kit mentioned in the List of Materials is being used. This kit includes breakaway headers, LED's, a breadboard, a buzzer, jumper wires, an Arduinio Uno, and several other components.

1.) Install the Arduino software to your computer
2.) Solder a 7 pin header to the MaxSonar, I used a 90 degree header found here,
     so the sensor faces away from the Arduino.
     For instructions on soldering, SparkFun has a great tutorial seen here.
3.) Place the sensor on the breadboard, make sure to leave room for wiring and other components.
     3a.) Place a red jumper between the sensor V+ and the + strip on the breadboard.
     3b.) Place a blank jumper between the sensor GND and the (-) strip on the breadboard.
4.) Wire the Arduino to the breadboard
     4a.) 5V to the + strip on the breadboard (allows power to multiple devices at one time)
     4b.) GND to the (-)strip on the breadboard (grounding for multiple devices at once)
     4c.) Wire Arduino signal input to the breadboard row with the sensor output signal.
5.) Connect the Arduino to the computer. Please allow time for the computer to install the Arduino Drivers.

Top of the Page

Wiring Images

Wiring an Arduino for Analog Voltage Wiring an Arduino for Pulse Width

Top of the Page

Author: Kathy Kostal  Date: 08-31-2016
Inc 5000 Maxbotix Logo Inc. Magazine Unveils 35th Annual List of America's Fastest Growing Private Companies–the Inc. 5000. MaxBotix Inc., Ranks No. 1752 on the 2016 Inc. 5000 with Three–Year Sales Growth of 213%.
Click here for full article.
Author: Cody Carlson  Date: 08-02-2016
Raspberry Pi 2 board MaxSonar sensors offer a variety of outputs including TTL serial data. This tutorial guides you through the process of setting up your Raspberry Pi 3 with a MaxBotix sensor. Click here for full article.
Author: Scott Wielenberg  Date: 07-26-2016
Full Horn Housing MaxBotix offers an expanded range of packaging options for many of our sensors. Each option provides unique benefits to certain mounting integrations. This article provides a brief overview of each option.
Click here for full article.
Author: Scott Wielenberg  Date: 07-18-2016
Sensor is Tested When providing support, our technical support team may determine that further testing at our facility is the best way to help resolve the issue that you are facing. At this point, they will start the Return Merchandise Authorization (RMA) process. This article will explain what you can expect as your ultrasonic sensor travels through our RMA process.
Click here for full article.
Author: Scott Wielenberg  Date: 07-11-2016
Typical Wall Pipe Many customers have requested the option to mount an ultrasonic sensor in a pipe. During the testing and development cycle, we discovered a number of considerations and requirements that must be met for the application to be successful. When all of these are met, a user may be able to achieve the desired level of success for measuring the liquid level inside of a pipe.
Click here for full article.
Author: Jenney Grover  Date: 06-28-2016
one of the options for outputs On April 19th, we welcomed our supporters to join us for the Grand Opening of the Build Out. Bob and Nita Gross gave a tour of the build out and their vision for the space. We continue to be in awe of the support from our community, our employees, our distributors, and our customers. Thank you for the many years of support, and we look forward to serving you in the years to come.
Click here for full article.
Signup for notification of our exciting new products and periodic new letters. We are excited to provide the latest information from MaxBotix Inc.