Read value of ultrasonic distance sensor.
Namespace:
AForge.Robotics.LegoAssembly: AForge.Robotics.Lego (in AForge.Robotics.Lego.dll) Version: 2.2.3.0 (2.2.3.0)
Syntax
| C# |
|---|
public bool GetUltrasonicSensorsValue( NXTBrick..::.Sensor sensor, out int value ) |
Parameters
- sensor
- Type: AForge.Robotics.Lego..::.NXTBrick..::.Sensor
Sensor to read value from.
- value
- Type:
System..::.Int32
%
Distance value obtained from ultrasonic sensor, [0..255] cm.
Return Value
Returns true if command was executed successfully or false otherwise.
Remarks
The method retrieves value of ultrasonic distance sensor by communicating with I2C device (writing to and reading from low speed bus). The method first sends { 0x02, 0x42 } command to the specified device using LsWrite(NXTBrick..::.Sensor, array<Byte>[]()[], Int32) method. Then it waits until there is something available to read using LsGetStatus(NXTBrick..::.Sensor, Int32%) method. Finally it reads sensor's value using LsRead(NXTBrick..::.Sensor, array<Byte>[]()[], Int32%) device. See this page for details.