Merge pull request #14896 from SteWers/SR04-dev

[SR04] fix mode 1 detection
This commit is contained in:
Theo Arends 2022-02-19 14:36:05 +01:00 committed by GitHub
commit 317830aeb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -136,6 +136,7 @@ void Sr04TModeDetect(void) {
sonar_serial = nullptr; sonar_serial = nullptr;
} }
sonar = new NewPing(sr04_trig_pin, sr04_echo_pin, SR04_MAX_SENSOR_DISTANCE); sonar = new NewPing(sr04_trig_pin, sr04_echo_pin, SR04_MAX_SENSOR_DISTANCE);
delay(100); // give time to inizialise, preventing ping_median fails
if (!sonar || !sonar->ping_median(5)) { if (!sonar || !sonar->ping_median(5)) {
SR04.type = SR04_MODE_NONE; SR04.type = SR04_MODE_NONE;
} }