Search This Blog

Tuesday, May 28, 2013

HC-SR04 ultrasonic range finder (max 4000mm)

I built some time ago a "range finder" based on the cheap ultrasonic module HC-SR04 (max 4000mm). I wrote a small program in Mikrobasic and have the result displayed on a 8x2 LCD. All needed is here:
HEX, source, sch, brd (EAGLE), datasheet, pictures

A video to show how it works:
Youtube video

Note theconnections to 16F630 PIC:
LCD_RS as sbit at RC5_bit
LCD_EN as sbit at RC4_bit
LCD_D4 as sbit at RC3_bit
LCD_D5 as sbit at RC2_bit
LCD_D6 as sbit at RC1_bit
LCD_D7 as sbit at RC0_bit
RA.5 is output for trigger input of the HC-SR04, RA.4 is input from the echo output of the HC-SR04. The LED on RA.0 is for testing only.

The push-button triggers (by powering the assembly), so the distance is displayed. No consumption unless push-button is pressed.

More explanations, see these links:
http://www.mikroe.com/forum/viewtopic.php?f=97&t=53891
http://www.mikroe.com/forum/viewtopic.php?f=97&t=54466

Some pictures
Overview:
 LCD display:
Inside the box (note the 12V battery wrapped in 3M band - I could not fit a 9V battery, and a 6V would not work as I have a regular 78L05):

UPDATE 2013/11/16: cod for 16F877a also available Source+HEX .
Connections:
    LCD_RS as sbit at RB7_bit
    LCD_EN as sbit at RB6_bit
    LCD_D4 as sbit at RB5_bit
    LCD_D5 as sbit at RB4_bit
    LCD_D6 as sbit at RB3_bit
    LCD_D7 as sbit at RB2_bit
    RB1=trigge
    RB0=echo received
    RC7 is output (LED) continuously ON.

1 comment: