diff --git a/src/HCSR04.cpp b/src/HCSR04.cpp index afe483c..8782d13 100644 --- a/src/HCSR04.cpp +++ b/src/HCSR04.cpp @@ -40,7 +40,9 @@ float UltraSonicDistanceSensor::measureDistanceCm(float temperature) { } // Measure the length of echo signal, which is equal to the time needed for sound to go there and back. + noInterrupts(); unsigned long durationMicroSec = pulseIn(echoPin, HIGH, maxDistanceDurationMicroSec); // can't measure beyond max distance + interrupts(); float distanceCm = durationMicroSec / 2.0 * speedOfSoundInCmPerMicroSec; if (distanceCm == 0 || distanceCm > maxDistanceCm) { @@ -48,4 +50,4 @@ float UltraSonicDistanceSensor::measureDistanceCm(float temperature) { } else { return distanceCm; } -} \ No newline at end of file +}