problem with microsecondsToInches

Hi
i am having an issue with the following program
i keep getting an error
ping_servo_buzzer.ino:53: error ‘microsecondsToInches was not declared in this scope’
i have tried many things but still look at the code below to see what i have done wrong.

thanks
chilliman

code:

#include <Servo.h> // include the servo library
#include <LiquidCrystal.h> // include lcd library

Servo servoMotor; // creates an instance of servo object to control a servo
LiquidCrystal lcd(12,11,6,5,4,3);// int the lcd library

const int pingPin = 10; // control pin for ping sensor
const int servoPin = 8; // control pin for servo motor
const int speakerPin =9; // control pin for speaker

int moveServoLeft =0;
int moveServoRight =0;

void setup()
{
// setup the lcd 's # of rows and columns
lcd.begin(16,2);
// initial display
lcd.setCursor(0,0);
lcd.print(“Distance(inch)”);
lcd.setCursor(0,0);

servoMotor.attach(servoPin); // attach the servo on pin 8
servoMotor.write(0); // set servo to intial position

moveServoLeft = 1; // int motion of servo is from 0 to 180

}

void loop(){

//get distance long
long duration, inches, cm;
// set speaker pin a nd servo to output
pinMode(speakerPin,LOW);
pinMode(servoPin, OUTPUT);
digitalWrite(speakerPin,LOW); //sound buzzer is defalut switched off

//ping sensor is two pulse high
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin,LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
// more ping sensor
pinMode(pingPin,INPUT);
duration = pulseIn(pingPin, HIGH);

// convert the time into a distance

inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);

delay(200);
lcd.clear();
//set cursor to col 0, line 1
lcd.print(“Distance (inch)”);
lcd.setCursor(0,1);
lcd.print(inches):
// to enable tracking servo
if(inches >=5){
servoMotor.attach(servoPin);
servoMotor.write(servoPosition);
delay(20);
// to move right if the motor has reached 180 deg

if(servoPosition == 180 && moveServoLeft ==1){
moveServoRight = 1;
moveServoLeft =0;
}
// to move left if the motor has reached 0 degress
if(servoPosition == 0 && moveServoRight == 1){
moveServoLeft =1;
moveServoRight = 0;

}
//move left from0 to 180

if(moveServoLeft == 1 & moveServo<= 160)
servoPosition = servoPosition + 20;
//move right from 180 to 0

if(moveServoRight == 1 & servoPosition >=0)
servoPosition = servoPosition-20;
}
// to disable trace of objrct is lesser that 5"king to servo motor is detached if the distance

else{
servoMotor.detach();
for(int duration =0 ; duration <100; duration ++){
digitalWrite(speakerPin,HIGH);
delayMicroseconds(200);
digitalWrite(speakerPin, LOW);
delayMicroseconds(200);
}
}
}

long mircosecondsToInches(long microseconds)
{
return microseconds / 74 /2;
}
long mircosecondsToCentimeters(long microseconds)
{
return microseconds /29/2;
}
/code:

Check your spelling:

inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration);

long mircosecondsToInches(long microseconds) long mircosecondsToCentimeters(long microseconds)

Also, why bother making these a function?

hi. it was a spelling mistake is working. but a problem with the lcd connection i am going to look at the lcd in the next few days

chilliman:     return microseconds / 74 /2;

Watch out with stuff like this. Calculations may go right, but to the user it's not always clear what is intended. Is it msecs / 38:

return microseconds / (74/2);

or msecs / 148 ? Better use some brackets.

return (microseconds / 74)/2;

And if the number 36 is project dependent, i'd suggest using a constant, like CENTIMETERS_PER_MSEC. Edit: thanks for the correction.

or msecs / 144 ?

sp. "148"