loading

Hey Everyone

Today I hope to teach you all about ultrasonic sensors and hopefully by the end you'll have a nice little digital tape measure of your own to use as you please.

Enjoy

Step 1: Parts List

This is my second version of this project so if you can get it as small or just don't feel like dealing with the Arduino Pro mini feel free to change it in any way you want.

To start off we will need:

  1. Arduino pro mini (Get it h ere)
  2. 10K potentiometer (Get it here)
  3. A 16x2 LCD (Get it here)
  4. A Ultrasonic sensor (Get it here)
  5. A battery and battery connector (I originally used a 9v but it proved to much for the Pro mini so i switched to 4.5V)
  6. Wire
  7. A Switch (Get it here)

The Tools you'll need:

  1. Soldering Iron and solder
  2. Wire cutters/strippers
  3. breadboard (for testing)
  4. Something to make you case out of (I used flat cardboard)
  5. Glue gun and glue sticks
  6. Cutting Knife

Step 2: Plotting It

This is the most important part if you are focusing on getting A small and neat package, If you just want it to work you can skip this step

To start you're going to want to find a configuration were your components are closest together for me that was the LCD on top of everything which ended very well because the LCD pin lined up with the Arduino pins thus lowering the amount of wire I need.

You can see how I plotted mine in the gif above, just beware I didn't end up using the 9v battery, my final battery pack ended up being three AAA batterys on the outer back of my device which made it easier for battery changes.

Step 3: The Wiring

If you're using the Arduino pro mini or a Arduino were you need to solder to pins, this will probably be the worst part. It will be worth it, I hope :D.

The pin configuration will be the same with all Arduinos so don't worry about changing the pin layout or code.

When I refer to LCD pins look at picture from right to left

  • LCD pin 1 to GRD
  • LCD pin 2 to Vcc (power)
  • LCD pin 3 to the middle pin on the potentiometer
  • LCD pin 4 to Arduino pin 12
  • LCD pin 5 to GRD
  • LCD pin 6 to Arduino pin 11
  • LCD pin 7 to Nothing
  • LCD pin 8 to Nothing
  • LCD pin 9 to Nothing
  • LCD pin 10 to Nothing
  • LCD pin 11 to Arduino pin 5
  • LCD pin 12 To Arduino pin 4
  • LCD pin 13 To Arduino pin 3
  • LCD pin 14 To Arduino pin 2
  • LCD pin 15 to Vcc (power)
  • LCD pin 16 to GRD

    potentiometer Right pin to GRN

  • potentiometer Middle pin to LCD pin 3

  • potentiometer left pin to Vcc

  • Ultrasonic Right pin (GRD) to GRD

  • Ultrasonic Right middle Pin (Echo) to Arduino pin 3

  • Ultrasonic Left middle pin (Trig) To Arduino pin 8

  • ultrasonic Left pin (Vcc) to Arduino pin 7

    Step 4: The Code

    <p>#include 
    <br></p><p>LiquidCrystal lcd(12, 11, 5, 4, 3, 2);</p><p>int pingPin = 7;
    int inPin = 8;
    long duration, inches, cm;
    int indec, cmdec;
    int inchconv = 147;
    int cmconv = 59;
    String s1, s2;</p><p>void setup() {
      lcd.begin(16, 2);
      pinMode(pingPin, OUTPUT);
      pinMode(inPin, INPUT);
    }</p><p>void loop()
    {
      digitalWrite(pingPin, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(pingPin, LOW);</p><p>  duration = pulseIn(inPin, HIGH);</p><p>  inches = microsecondsToInches(duration);
      indec = (duration - inches * inchconv) * 10 / inchconv;
      cm = microsecondsToCentimeters(duration);
      cmdec = (duration - cm * cmconv) * 10 / cmconv;
      s1 = String(inches) + "." + String(indec) + "in" + "     ";
      s2 = String(cm) + "." + String(cmdec) + "cm" + "     ";
      lcd.setCursor(0, 0);
      lcd.print(s1);
      lcd.setCursor(0,1);
      lcd.print(s2);</p><p>  delay(900);
    }</p><p>long microsecondsToInches(long microseconds)
    {
      return microseconds / inchconv;
    }</p><p>long microsecondsToCentimeters(long microseconds)
    {
      return microseconds / cmconv;
    }</p>

    Step 5: Uploading the Code

    Now for the most part this step is useless if you're using an Arduino with serial communication (Arduino uno, Nano) However if you're using a Arduino Pro Mini like me you'll soon find that there is no USB port to plug it in! To solve this problem you will need a serial programmer or an Arduino Uno (im using the uno to program my mini)

    Connect arduino uno board 5V pin to pro mini’s VCC pin.

    Connect arduino uno board GND pin to pro mini’s GND pin.

    Connect arduino uno board TX pin to pro mini’s TX0 pin.

    Connect arduino uno board RX pin to pro mini’s RXI pin

    Connect arduino uno board RESET pin to pro mini’s RST pin.

    Then in the Arduino IDE select Arduino pro mini as the uplaod board. Once all this is done you should be ready to upload.

    Step 6: The Casing

    Finally you can choose a material to make your case out of. Preferably A hard ridged cut-able material that can be glued. (Thin wood, Cardboard, Card stock, sheet metal just don't forget to insulate it) Now unfortunately i cant really help you with this step as everyone's final wiring and size will be different all i can say is make sure you measure and glue as accurate as possible and most important of all make it yours. :)

    Thanks for reading and as always please feel free to message me at anytime for assistance.

    DR

    <p>This is a great idea. I think I'll try to make this tonight!</p>
    <p>Good luck and enjoy! Please let me know if you have any questions</p>
    Can somebody please answer my question? -<br>Is it okay if i don't you the potentiometer<br><br>
    what is tape measure?measuring the physical tape wire or distance?
    Hello,<br>When I copied the code, I get this error (screenshot below)<br><br>when I type the code and I checked the code, it appears in an error message screen:<br><br>stray'#'in program<br>exit status1<br>stray'#'in program<br><br>could you help me?<br>thank you very much
    <p>Hello,<br>When I copied the code, I get this error (screenshot below)</p><p></p><p></p><p><br>could you help me?<br>thank you very much</p>
    <p>Hey i would love to help but i dont see the screen shot, try reposting it.</p>
    <p>I made my own version of this and wrote an <a href="https://www.instructables.com/id/Digital-Ultrasonic-Tape-Measure/">Instructable</a> for it. Thanks for the good idea!</p>
    This is so good!
    Can I just in use the arduino uno instead of pro mini? <br><br>
    <p>Good work, I would like to make one of these, but first of all, some comments:</p><p>The code as presented here doesn't compile for me. I had to get rid of the </p><p>&laquo;&lt;/p&gt;&lt;p&gt;&raquo; thing and I added to #include &laquo;&lt;LiquidCrystal.h&gt;&raquo;. Now it is compiling </p><p>with Arduino 1.6.5. I will tell you how is it going. Thanks.</p>
    is it possible to expand the range of the measurement author? by the way great instructables
    <p>you could but you would lose accurac</p>
    <p>What range and accuracy are you getting with your system?</p>
    <p>It's very interesting, but you could write simply cm=us/58 or similar for inches :-)</p>
    Awesome idea! And by second decimal place accuracy, what unit do you mean? cm? <br><br>Have a great day! :-)
    Range is 9 meters accuracy is about the second decimal place
    <p>Might be nice to get some info on use. Range? Accuracy?......</p>

    About This Instructable

    15,807views

    175favorites

    License:

    Bio: I'm a 18-year-old high school student, I love engineering, film production, design and everything in between.
    More by electronics for everyone:Salvaging Rechargeables for Projects  Portable Light Panel  Can I Use an Arduino Uno for This? 
    Add instructable to: