loading

Today everything is digitalized. Most of us don't bother to waste our time using maps, going to the record store, or even going to the DVD store anymore. So... why are so many people using tape-measures and rulers? Yes, they are reliable, but they are certainly not convenient. With innovations, such as ultrasonic range sensors, we have entered a time where you don't have to bother getting out your old tape-measurer. Using this pocket-sized ultrasonic ruler, you can simply point at any object, click a button, and the distance will be displayed on the 8 LED display. And you don't have to pay hundreds of dollars, like most commercially available ultrasonic measurers. This ruler is the smallest (5cm by 7cm) and cheapest (about 5 USD) ultrasonic measuring device available today.

Although the ultrasonic range sensor is widely used, I haven't seen many DIY devices that simply act as rulers. Its main application seems to be in robotics. However, in robotics typically the precision of the sensor is not fully used. I found that this sensor is so precise that its ability to determine distance is enough to make a ruler. This prototype is accurate to +/- one centimeter, which is great for quick measurements and can be more efficient than a physical ruler.

Step 1: Parts

You will need these parts:

-Attiny85 (with socket)

-74hc595 Shift Register

-7805 Voltage Regulator

-HC-SR04 Ultrasonic Range Sensor

-Eight 330 Ohm Resistors

-One Tactile-Switch Button

-One Two-way Slide Switch

-Eight LEDs

-One Indicator LED (with 2k resistor)

-Perfboard (5cm by 7cm)

-9v Battery (with connector)

You will need these tools:

-Computer

-Soldering Iron (with rosin)

-Another Arduino (for programming attiny)

-Hot Glue Gun

You will need these skills:

-How to program an attiny

-How a 74hc595 works

-Basic arduino programming skills

<p>great project</p><p>can i place your project on my website.</p><p>i'm working on a website which is related to electrical projects.</p><p>i also mention your name, link and other info.</p><p>plz reply</p>
<p>Hello, i have some problems with your code. I use the Arduino IDE 1.6.5 and if I upload the code, this message will come:</p><p>Arduino: 1.6.5 (Windows 7), Platine: &quot;ATtiny, ATtiny85, 8 MHz (internal)&quot;<br><br>ultrasonic_ruler.ino: In function 'void setup()':<br>ultrasonic_ruler:15: error: 'Serial' was not declared in this scope<br>'Serial' was not declared in this scope</p><p>Please help me...</p>
<p>Nice Project. I have made a smilar one. But mine is talking according to distance :) You can check my project. :)</p><p><a href="https://www.instructables.com/id/Arduino-wtv020-Sd-..." rel="nofollow">https://www.instructables.com/id/Arduino-wtv020-Sd-...</a></p>
<p>How can I program ultrasonic HC-SR04 with AVR?please help......SOS</p><p>I want to use it as a meter </p>
<p>The arduino IDE still won't let me upload this code, I've tried many versions and using an UNO and a Tiny AVR Programmer but no luck... I would really like to finish this project because I've bought all the pieces. I've tried using different releases of the IDE but that hasn't helped. If anyone knows what might be wrong or has any advice/input/a gut feeling or maybe had this problem please help! :) </p>
<p>I made one with a few modifications! </p>
<p>That's too cool! I love the PCB. It looks like you used two ATMega328s? Can you share exactly what you did? Great work and thanks for sharing!</p>
<p>Yes, I used two 328s - one for the for the LCD &amp; Ultrasonic Sensor, and the other for all my leds. I wrote up my code so that a single led turns on every 2inches. Looking back I should have used a shiftregister (to control the leds) but I was running out of time and did not have time to order any. I won first place at my wife's family reunion for adult project hahaha. Thanks for the idea. </p>
<p>Nice! That's definitely an original way to make it. Also there are some great modules out there that allow you to control LCDs using I2C which could save you like.. 6 pins. But either way your version looks awesome!</p>
<p>impressive!</p><p>is it possible to use number led panel replacing line of led?</p>
<p>Take a look at this instructable:</p><p><a href="https://www.instructables.com/id/Animated-Sonic-Ruler-Parking-Sensor-using-Arduino/" rel="nofollow">https://www.instructables.com/id/Animated-Sonic-Rul...</a></p><p>Here's the video of it actually working:</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/PvgGS8EdRwY" width="500"></iframe></p>
<p>Which arduino did you used, arduino uno or arduino mega?</p><p>Please tell me</p><p>Thanks :)</p>
<p>I used an arduino mega 2560 to program the attiny85. An Attiny85 is an arduino chip that can be programmed just like any other arduino, but it only has 5 i/o pins. </p>
<p>and Congrats for winning the competition :-)</p>
<p>Thanks for answering i will start my project as soon as i get all the components :-)</p>
<p>Arduino Uno. The thing you see upon it is a arduino uno prototyping board. =)</p>
<p>Thanks :-) Hope i will get all the required components and it works :-)</p>
cool
<p>Thank you! And hmm when you say &quot;number led panel&quot;, do you mean a 7-segment display? (Such as a digital alarm clock display?) If you do, than yes you may certainly use one; however, you will need one or two 74HC595s in your circuit (depending on the number of digits you want to use). You could even attach a 8x8 LED matrix to this circuit since all you would need is two 74HC595s to drive it.</p>
you can use an i2c 8x1 lcd display instead of 7segments display... a nokia display is out of discussion because it uses SPI comunication and needs too many pins. of course it can be done with atmega328, but it's not gonna be as fun as attiny85
oh i see<br>thank you for your answer.
<p>Can i use an arduino uno for this?</p><p>Please tell me</p><p>Thanks :)</p>
<p>Yes you may use an uno for this, however, one of the purposes of this device was to make it very small and portable. For testing purposes the uno would do just fine but I suggest getting some attiny chips later on. Thanks! </p>
<p>Thanks for answering i will start my project as soon as i get all the components :-)</p>
<p>Nice project. Congrats on winning the sensor's contest.</p><p>How much range do you get with HC-SR04? I'm trying to use one but it only gives range of about 30-40cm instead of the promised 400cm.</p>
<p>I believe the datasheet said it has a distance of 200cm. However, a good way to troubleshoot is to hookup your SR04 to a spare microcontroller, and write code that outputs the sensor's data to the serial console. If it is still reading 30-40cm, I'd buy a new sensor. If it reads up to 200cm, then it is probably just your 74hc595 acting up. If so, check for shorts and the schematic again! Thanks for commenting</p>
<p>I tried it with an Arduino and got reading on serial for 30-40cm only. I guess it is busted. Have ordered new ones. Thanks for your help :)</p>
<p>When I try and upload the sketch I get the error message that 'Serial' was not declared in this scope for the &quot;Serial.begin (9600);&quot; line, I copied and pasted this example so I'm not sure where I went wrong or how to fix this. Help please! :)</p>
<p>Make sure you are using the latest version of the arduino IDE. Here is a link to the updated version: <a href="http://arduino.cc/en/main/software" rel="nofollow">http://arduino.cc/en/main/software </a> </p><p>Thanks for the comment!</p>
<p>simple and cool</p>
Congrats on winning 2nd place with this little gem in the Sensors Contest! Should've been higher, but it is hard to beat a fingerprint scanner
<p>Thanks! Haha yeah right after I saw the LED Beer Pong and that Finger print scanner I knew it would be a tough contest, but it was still awesome to win something! </p>
Great device, great design, and great tutorial. Well written and easy to follow. I now have a use for the Attiny85 I bought a while ago.
<p>Thank you very much! If you have any issues or suggestions please let me know</p>
How can I a lcd and make it display measurement in inches??
<p>Take a look at this instructable:</p><p><a href="https://www.instructables.com/id/Animated-Sonic-Ruler-Parking-Sensor-using-Arduino/" rel="nofollow">https://www.instructables.com/id/Animated-Sonic-Rul...</a></p><p>Here's the video of it actually working:</p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/PvgGS8EdRwY" width="500"></iframe></p>
<p>1. To use an LCD, you will need to use a shift register (such as the 74HC595) with the attiny. The process is described at this instructable: <a href="https://www.instructables.com/id/ATTiny4585-LCD-display-control-with-a-shift-regis/" rel="nofollow">https://www.instructables.com/id/ATTiny4585-LCD-dis...</a> </p><p>2. To make the LCD display inches, in the code you will have to add this line &quot;distance = distance * 0.393701&quot; right before you see &quot;shiftOut&quot;. Also you will have to replace the &quot;shiftOut&quot; line with something such as this: &quot;lcd.print(distance)&quot; . (replace the word &quot;lcd&quot; with whatever you named your object of the Liquid Crystal Library). </p><p>Thanks for your interest in the project, don't hesisate to ask more questions!</p>
<p>great project. I wanted some help with it. I connected everything as per your guide and uploaded the code to the attiny85 but it does not seem to be working right. it is not displaying in binary, for anything under 10cm it is turning Qa on the 74hc595 on, under 12cm it is turning Qb on, 60cm it turned on Qa,Qb,Qc.</p>
<p>Sorry I couldn't respond sooner, but I could help you troubleshoot. Be sure that all of your LEDs are functioning properly. (check for any burnt out LEDs). Then be sure there are no shorts to the &quot;CLR&quot; or &quot;RST&quot; pins on the 74HC595. I believe those pins are close the the VCC and GND so just make sure they don't connect to the other pins. Did you use my exact code? Thanks for your interest!</p>
<p>Cool little project! ;)</p><p>You can buy the HC-SR04 ultrasonic range sensor for cheap on this webstore:</p><p><a href="http://voltatek.com/en/sensors/22-hc-sr04-ultrasonic-module-range-finder.html" rel="nofollow">http://voltatek.com/en/sensors/22-hc-sr04-ultrason...</a></p><p>They ship from Canada.</p>
<p>Nice link! I actually ordered mine from an ebay seller from china and got two HC-SR04s for under $3. Pretty good deal but you've gotta have patience haha </p>
While quite a nice idea, this isn't really practical as a replacement for a tape measure. <br>These are already sold as &quot;distance estimators&quot; and are prone to error from reflections, &amp; of course, are at best within 10mm. Try cutting a board to that then fitting it! <br>Nice Instructable though.
<p>Although this is definitely a useful item, I use tape measures and rulers as much as possible specifically because they do not require power cells. Two thumbs up for pioneering!!</p>
<p>Except, of course, that measuring is actually only a secondary function of rulers and tape measures. The real purpose of those devices is locating points at known dimentions, and, in the case of rulers, drawing straight lines.</p>
<p>Good call! You're right it certainly cannot replace some of the ability of rulers, however, it is a pretty handy device! </p>
<p>May I ask what the range of it is?</p>
<p>200 centimeters that is. Sorry </p>
<p>Yes of course! I believe the sensor has a max range of 200 and the binary display can only display 255 digits. Thanks! </p>
<p>Nice instructable! Great use of the ATtiny85! =D</p>
<p>Thank you! If you do the project I'd love to see some pictures! </p>

About This Instructable

49,163views

713favorites

License:

Bio: I'm a student at UW-Milwaukee studying computer science with a passion for electronics. I'm always working on a project or thinking of new ... More »
More by bergerab:Flame Controlled MIDI Controller SOLO Cup Speaker Backpack Anti-Theft Alarm 
Add instructable to: