Sonar Class

Uses sonar to calculate distance by sending a ping and measuring the time lapsed before receiving the echo. The maximum distance that can be measured is 165 Centimetres. Sonar works best to detect objects with hard surfaces that reflect sound well. The sonar sensor may detect a closer object off to the side instead of a farther object straight ahead. The Arduino pins assigned for the sonar module are configured in the firmware settings.

Definition

Namespace: RoboTx.Api
Assembly: RoboTx.Api (in RoboTx.Api.dll) Version: 1.0.0
C#
public sealed class Sonar
Inheritance
Object    Sonar

Properties

DistanceAcquired Returns true if a distance value has been calculated from the sonar echo. Returns false if no echo was received in time.

Methods

Clear Clears the current distance value.
GetDistance Gets the distance calculated from the sonar echo after calling Ping(). A value of -1 indicates no echo was received in time. Note that a call to this method will reset the distance to -1. Therefore, the caller should store the value returned in a variable.
Ping Sends one ping using a sonar module.

See Also