Add a 50 ms timeout to the pulseIn(...) statement.
The code will hang with a Security Token loop if this delay is not present.
@@ -22,7 +22,7 @@ void UltrasonicDistance::enable() {
yield();
}
digitalWrite(trigger_pin, LOW);
- this->emit(pulseIn(input_pin, HIGH));
+ this->emit(pulseIn(input_pin, HIGH, 50000)); // 50 ms timeout
});
}
