Before I made this instructable I had just gotten some new Attinys (Attinies?) and wanted to make something with them. That's when I noticed my ultrasonic range finder all alone being unused. This ultrasonic Attiny distance finder gives the distance through a series of flashing LEDs and can even be switched from CM to IN by holding the button for long enough.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Gather Materials
Sorry, most of the links are for items in bulk but they're cheap and are what I used.
- Attiny85/45 - Prices on Ebay can be found for around $2.00 but listings end quickly so here's Amazon
- 8 Pin Socket
- Slide switch
- Ultrasonic Distance Finder
- Leds x 3 (Any color)
- Resistors that go with selected color for 5v http://led.linear1.org/1led.wiz (helpful resistor calculator)
- Perfboard - $6.99 for 5. Also look on Ebay.
- Nine volt battery + holder
- 5v voltage regulator
Step 2: Built the Circuit
If you want you can test this on a breadboard to make sure everything is in order, or you can go straight to a perfboard (or create your own PCB).
port number (pin Number)
- Ultrasonic echo + Trig pin >>> 2 (7)
- Button ------------------------- >>> 1 (6)
- 50s LED ---------------------- >>> 0 (5)
- 10s LED----------------------->>> 4 (3)
- 1s LED ------------------------ >>> 3 (2)
Feel free to change these anyway that's easiest to make. I set it up this way because it looked the nicest on Fritzing :)
Step 3: Program the Attiny
Also, MAKE SURE to download the New Ping library as that is how I can have the echo and trig on the same pin. If you don't know how to add a library, download the .zip from the link then go to
Sketch > Include Library > Add .zip Library > Downloads > NewPing*.zip
*Please don't say that you are getting errors while compiling without first adding the library!*
And here is the code.
Step 4: Using It
Basically now it's just point and shoot (well, press).
To give the distance there are three LEDs. One meaning 50, 10, and 1 respectively. For example, if the distance is 67 then the 50 LED will flash once, the 10 will flash once and the 1 will flash seven times. All adding up to 67. (50 + 10 + 7= 67).
To switch it from CM to IN or vice versa hold the button for over two seconds. Depending on what it is currently on (Its default is CM) all the LEDs will flash to indicate what it got set to.
Solid light on then off == CM to IN
Flashing light ---------- == IN to CM
If you have any questions feel free to ask!
Participated in the
Arduino Contest 2017