Sei sulla pagina 1di 7

Food

Living

Outside

Play

Technology

Workshop

Arduino ultrasonic range finder, with lcd display!


by Jan_Henrik on April 3, 2014

Table of Contents
Arduino ultrasonic range finder, with lcd display! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Intro: Arduino ultrasonic range finder, with lcd display! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 1: What do you need & Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 2: The Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 3: The Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 4: Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 5: Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Step 6: Finishing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

http://www.instructables.com/id/Arduino-ultrasonic-range-finder-with-lcd-display/

Intro: Arduino ultrasonic range finder, with lcd display!


Hello,
in this project i want to show and explain you a range sensor with ultrasonic and a 20x04 lcd screen. I wrote the code for this project myself and added lots of comments,
so that everybody can understand it and use it for other projects (maybe a light range sensor?!). It is easy to build and much more easier to program, it just requires a few
cheap parts and can run on battery, for a portable rangefinder.
The maximum rated range is 500 cm, the range is measured 20 times per seccond. it is Displayed on a lcd screen which is 20x4 chars big, it has a custom start
message, and it can have a custom design while measuring. It will have a backlight LED and can run on every arduino, which has IC communication. That mean you
can run it on an Arduino nano, which is very small. It also requires 5V so it has to be a 5V version of an Arduino.

Image Notes
1. Arduino
2. Ultrasonic sensor
3. Display 20x04 chars
4. Random parts, not
necessary but recommend ;P

Step 1: What do you need & Tools


We dont need much things, the parts should be less then 15$ (without arduino, with arduino may 25-35$):
Parts:
Arduino (5-55$) , http://tinyurl.com/pk2wdt3
Ultrasonic sensor (2$), HC-SR04 , http://tinyurl.com/d3ss7tl
A 20x4 Display (6$) , http://tinyurl.com/pbk35ry
A IIC/I2C/TWI/SP I Serial Interface Board Module (2$) , http://tinyurl.com/nl2tr2k
Some wires
a Breadboard
A USB cable
Software:
Arduino , www.Arduino.cc
wire.h library (should be with the Arduino software)
LiquidCrystal_I2C.h library for the Display
NewPing.h library for the sensor
Tools:
what are tools? D:
(no tools needed, yay)
Additional:
a Case...

Image Notes
1. Cables

http://www.instructables.com/id/Arduino-ultrasonic-range-finder-with-lcd-display/

2. Ultrasonic sensor, module HC-SR04


3. Breadboard
4. Display 20x4
5. Display 20x4
Image Notes
1. IIC/I2C/TWI/SP I Serial Interface Board Module connected to the Display
2. The Display
3. Serial/Part Number
4. Jumper for the backlight LED
5. New output pins: GND VCC SDA SCL

Step 2: The Display


Now we need to connect the IIC I2C TWI SPI Serial Interface Board Module to the display, that allows us to easily use the Display with the IC bus of the Arduino ( nearly
every Arduino/Atmel processor can communicate with IC, it just need a SDA and a SCL pin). Solder the module to the display ( picture 2 ).
Take care of the heat, it can easily destroy the display and the module!!!

Image Notes
1. Cables
2. Ultrasonic sensor, module HC-SR04
3. Breadboard
4. Display 20x4
5. Display 20x4
Image Notes
1. IIC/I2C/TWI/SP I Serial Interface Board Module connected to the Display
2. The Display
3. Serial/Part Number
4. Jumper for the backlight LED
5. New output pins: GND VCC SDA SCL

http://www.instructables.com/id/Arduino-ultrasonic-range-finder-with-lcd-display/

Step 3: The Sensor


The ultrasonic sensor is a very good one, its part number is HC-SR04, it is one with a range of 1cm-500cm. It is a good build one, which is easy to handle and to use.

Image Notes
1. Ultrasonic emitter
2. Ultrasonic reciever

Step 4: Assembly
Lets assembly it, plug the VCC pins of the Display and the Sensor to the +5V pin of the Arduino, plug the GND pins of the Display and the Sensor to GND of the Arduino.
Now plug the TRIG pin of the Ultrasonic Sensor to pin 12 of your Arduino
and the ECHO pin to pin 11 of your Arduino.
Sensor:
VCC -> +5V
GND -> 0V
TRIG -> pin 12
ECHO -> pin 11

Plug the SDA pin of the display to pin A4 of your Arduino


and the SCL pin of the display to A5 of your Arduino
Display:
VCC -> +5V
GND -> 0V
SDA -> A4
SCL -> A5

http://www.instructables.com/id/Arduino-ultrasonic-range-finder-with-lcd-display/

Image Notes
1. Arduino
2. Ultrasonic sensor
3. Display 20x04 chars
4. Random parts, not
necessary but recommend ;P

Step 5: Code
Now my favorite chapter, because i wrote the code myself, what made my day, beacuse im not such a good programmer :)
The code is made for the Arduino Uno, you can find it here:
https://github.com/Jan--Henrik/Arduino-ultrasonic-rangefinder
I wrote many commands, to help you understanding it.
You can add a custom startup message (line 57), also you can add a custom design while measuring ( line 87 )
Feel free to comment bugs, addictions and things to make it better!!! :)
Also feel free to comment if you amde the code for other processors (like the Attiny85)!!

http://www.instructables.com/id/Arduino-ultrasonic-range-finder-with-lcd-display/

Step 6: Finishing
SUCCESS!!! :)
Now your first self build arduino range sensor should work!! congratulations!!
Ideas:
Code it for other processors/platforms
make a nice case
use other parts
troubleshooting:
Display shows bars:
unplug power source, then wait 5 secconds and plug it in again. Sometimes there is a bug, that the display dont refresh :/
may SDA and SCL are reversed
Sensor dont work:
TRIG and ECHO are switched
Display, Arduino and LEDs fade out:
you made a short circuit, unplug your power source immediately!!!!
Thank you for Reading, feel free to comment and Vote for me in a Contest!!!
greets Jan Henrik

Image Notes
1. Cables
2. Ultrasonic sensor, module HC-SR04
3. Breadboard
4. Display 20x4
5. Display 20x4

Image Notes
1. Arduino
2. Ultrasonic sensor
3. Display 20x04 chars
4. Random parts, not
necessary but recommend ;P

Related Instructables

ATTiny powered
Arduino
Projects - I
made it at
TechShop by
madebyjoe

Sound Ranging
for the Visually
Impaired using
Arduino
Prototype
Design Concept
by station420

Working Sonic
Screwdriver Version 3.0 by
The Props
Monster

ATTiny45/85
LCD display
control with a
shift register,
programmed in
Arduino by
baharini

Kerf Table Lamp


Using the
by gcatchpole
Arduino Uno to
program
ATTINY84-20PU
by tsant

http://www.instructables.com/id/Arduino-ultrasonic-range-finder-with-lcd-display/

Advertisements

Comments

http://www.instructables.com/id/Arduino-ultrasonic-range-finder-with-lcd-display/

Potrebbero piacerti anche