21 pinMode(triggerPin, OUTPUT);
24 pinMode(echoPin, INPUT);
38 digitalWrite(triggerPin, LOW);
42 digitalWrite(triggerPin, HIGH);
43 delayMicroseconds(10);
44 digitalWrite(triggerPin, LOW);
47 duration = pulseIn(echoPin, HIGH);
69 return distance * 2.54;
82 const float speedOfSoundInCMPerUS = 0.034;
93 void calculateDistance() {
94 distance = duration * speedOfSoundInCMPerUS / 2;
float getDistanceInInches()
Definition: Ultrasonic.h:67
bool inProgress()
Definition: Ultrasonic.h:77
void startMeasurement()
Definition: Ultrasonic.h:34
Definition: Ultrasonic.h:10
int getDistanceInCM()
Definition: Ultrasonic.h:57
Ultrasonic(byte trigger, byte echo)
Definition: Ultrasonic.h:19