Distance Sensor
This function is used when using distance sensors.
- Distance.Read(trigger, echo) - Uses ultrasonic sonic sensor to read distance.
trigger: The pin number that is connected to trigger (pulse) signal
echo: The pin number that is connected to echo signal, use-1
for single pin
Returns: Distance in centimeters
Tip
Most sensors need 5V to work.
This example will read distance, using pin 0 for trigger and pin 1 for echo pin.
while True:
x = duelink.Distance.Read(0, 1)
if x > 0:
print(x)
time.sleep(0.1)