Skip to content

Commit 8f69e91

Browse files
authored
Swap the note for example from example code
Updating based on PR comments
1 parent 58d27a7 commit 8f69e91

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ 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. Note trig and echo should come from the `board` module - they aren't just integers.
102+
de-initialize the device.
103103

104104
::
105-
105+
import board
106106
from adafruit_hcsr04 import HCSR04
107-
sonar = HCSR04(trig, echo)
107+
sonar = HCSR04(trigger_pin=board.D5, echo_pin=board.D6)
108108
try:
109109
while True:
110110
print(sonar.distance)
@@ -122,9 +122,9 @@ instance, again get the distance every 2 seconds, but then the context manager h
122122
us.
123123

124124
::
125-
125+
import board
126126
from adafruit_hcsr04 import HCSR04
127-
with HCSR04(trig, echo) as sonar:
127+
with HCSR04(trigger_pin=board.D5, echo_pin=board.D6) as sonar:
128128
try:
129129
while True:
130130
print(sonar.distance)

0 commit comments

Comments
 (0)