docs: fix sonar example

This commit is contained in:
Oleg Kalachev
2020-02-19 18:27:09 +03:00
parent 4c940f0b8b
commit e05431cc75
2 changed files with 4 additions and 4 deletions

View File

@@ -73,8 +73,8 @@ def read_distance():
global low
done.clear()
pi.gpio_trigger(TRIG, 50, 1)
done.wait(timeout=5)
return low / 58.0 / 100.0
if done.wait(timeout=5):
return low / 58.0 / 100.0
pi.set_mode(TRIG, pigpio.OUTPUT)
pi.set_mode(ECHO, pigpio.INPUT)

View File

@@ -73,8 +73,8 @@ def read_distance():
global low
done.clear()
pi.gpio_trigger(TRIG, 50, 1)
done.wait(timeout=5)
return low / 58.0 / 100.0
if done.wait(timeout=5):
return low / 58.0 / 100.0
pi.set_mode(TRIG, pigpio.OUTPUT)
pi.set_mode(ECHO, pigpio.INPUT)