Leong Kum Loong (NYP) / HCSR04

Dependents:   Utrasonic_Example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HCSR04.h Source File

HCSR04.h

00001 /*
00002     HCSR04.h
00003     Written by Leong Kum Loong.
00004     04 Dec 2017, REV. 0
00005     
00006     All routines and functions in this library are written by me solely.
00007     Library for HC-SR04 Ultrasonic Ranging sensor.
00008     Library uses pins p21 to send pulse to sensor Trigger input & p22 to read sensor Echo output.
00009     This is assuming velocity of sound rate from ultrasonic pulse is 340m/s.
00010 */
00011 
00012 #ifndef HCSR04_h
00013 #define HCSR04_h
00014 #include "mbed.h"
00015 
00016 //1 for CM & 2 for INCH
00017 void getDistance(int unit=1);
00018 
00019 //Read current distance.
00020 float readDistance();
00021 
00022 #endif