Table of Contents

Distance Sensor

This function is used when using a distance sensors.

  • ReadDistance(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.

@Loop
x = ReadDistance(0,1) 
If x>0 
    PrintLn(x)
End
Wait(100)
Goto Loop