HC-SR04 Ultrasonic receiver programming

I have been trying to use the above sensor in a project us the information on page 135 of Arduino Project Handbook with no success, it produces ‘0’ all the time . Could any user of this sensor using it successfully kindly oblige me with correct programming instructions which they know to work and pulse the sensor correctly.

This is main operative code I am using :-
#include <LiquidCrystal.h>

int pingPin = 13;
int inPin = 12;
LiquidCrystal lcd(11, 10, 9, 7, 6, 5, 4);

void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print(“Testing…”);
}

void loop() {
lcd.print(“Testing…”);
long duration, inches, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
duration = pulseIn(inPin, HIGH);

I don't have the book, so why don't you post your code and your schematic?

i have found that the "NewPing" library works well, it comes with several examples.

Well if that's all the code you have I see your problem. You appear to ping the sensor but you never read the result.

Steve

In the (incomplete and improperly posted) code You never read the echo so how do you expect any thing but 0?

There are forum guidelines that show how to properly post code and some good advice on what we need to know in order to help you.