Skip to content

Commit 58d27a7

Browse files
authored
Update to the correct distance call
It looks like the `distance property replaces the `dist_cm()` function. Also gave a hint here that the board pin objects are needed, and not just integers.
1 parent 6eee7ad commit 58d27a7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ Without a Context Manager
9999
-------------------------
100100

101101
In the example below, we create the `HCSR04` object directly, get the distance every 2 seconds, then
102-
de-initialize the device.
102+
de-initialize the device. Note trig and echo should come from the `board` module - they aren't just integers.
103103

104104
::
105105

106106
from adafruit_hcsr04 import HCSR04
107107
sonar = HCSR04(trig, echo)
108108
try:
109109
while True:
110-
print(sonar.dist_cm())
110+
print(sonar.distance)
111111
sleep(2)
112112
except KeyboardInterrupt:
113113
pass
@@ -127,7 +127,7 @@ us.
127127
with HCSR04(trig, echo) as sonar:
128128
try:
129129
while True:
130-
print(sonar.dist_cm())
130+
print(sonar.distance)
131131
sleep(2)
132132
except KeyboardInterrupt:
133133
pass

0 commit comments

Comments
 (0)