arduino + Ultrasonic คอมไพล์ไม่ผ่านครับ รบกวนผู้รู้

กระทู้คำถาม
สวัสดีครับ
   ผมคอมไพล์ โปรแกรมบน Arduino NAno ไม่ผ่านครับ  รบกวนผู้รู้ครับ
เตือนว่า
nano_ultra:24: error: 'microsecondsToCentimeters' was not declared in this scope

exit status 1
'microsecondsToCentimeters' was not declared in this scope


รายละเอียด

การต่อ Arduino nano --->Ultrasonic module (ที่ขายกันทั่วไป)


โค้ด
const int pingPin = 13;
int inPin = 12;


void setup() {
Serial.begin(9600);
}

void loop()
{
long duration, cm;

pinMode(pingPin, OUTPUT);


digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(inPin, INPUT);
duration = pulseIn(inPin, HIGH);

cm = microsecondsToCentimeters(duration);

Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToCentimeters(long microseconds)

{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่