
get_currentValue
The
get_currentValue()
method of the object returned by
yFindRangeFinder
allows you
to obtain the distance measured by the sensor, in mm or in inches depending on the sensor
configuration.
A real example
Launch Microsoft VisualBasic and open the corresponding sample project provided in the directory
Examples/Doc-GettingStarted-Yocto-RangeFinder
of the Yoctopuce library.
In this example, you will recognize the functions explained above, but this time used with all side
materials needed to make it work nicely as a small demo.
Module
Module1
Private
Sub
Usage
()
Dim
execname =
System
.
AppDomain
.
CurrentDomain
.
FriendlyName
Console
.
WriteLine
(
"Usage:"
)
Console
.
WriteLine
(
ex
" <serial_number>"
)
Console
.
WriteLine
(
ex
" <logical_name>"
)
Console
.
WriteLine
(
ex
" any "
)
System.
Threading
.
Thread
.
Sleep
(
2500
)
End
End
Sub
Sub
Main
()
Dim
argv
()
As
String
=
System
.
Environment
.
GetCommandLineArgs
()
Dim
errmsg
As
String
=
""
Dim
target
As
String
Dim
rf
As
YRangeFinder
Dim
ir
As
YLightSensor
Dim
tmp
As
YTemperature
If
argv.
Length
<
2
Then
Usage
()
target = argv
(
1
)
REM Setup the API to use local USB devices
If
(
yRegisterHub
(
"usb"
, errmsg
)
<> YAPI_SUCCESS
)
Then
Console
.
WriteLine
(
"RegisterHub error: "
+ errmsg
)
End
End
If
If
target =
"any"
Then
rf = yFirstRangeFinder
()
If
rf
Is
Nothing
Then
Console
.
WriteLine
(
"No module connected (check USB cable) "
)
End
End
If
target = rf.
get_module
()
.
get_serialNumber
()
Else
rf = yFindRangeFinder
(
".rangeFinder1"
)
End
If
ir = yFindLightSensor
(
".lightSensor1"
)
tmp = yFindTemperature
(
".temperature1"
)
While
(
True
)
If
Not
(
rf.
isOnline
())
Then
Console
.
WriteLine
(
"Module not connected (check identification and USB cable)"
)
End
End
If
Console
.
WriteLine
(
"Distance : "
+
Str
(
rf.
get_currentValue
()))
Console
.
WriteLine
(
"Ambiant IR : "
+
Str
(
ir.
get_currentValue
()))
Console
.
WriteLine
(
"Temperature : "
+
Str
(
tmp.
get_currentValue
()))
Console
.
WriteLine
(
" (press Ctrl-C to exit)"
)
ySleep
(
1000
, errmsg
)
End
While
yFreeAPI
()
End
Sub
End
Module
12. Using Yocto-RangeFinder with Visual Basic .NET
www.yoctopuce.com
73
Содержание Yocto-RangeFinder
Страница 1: ...Yocto RangeFinder User s guide...
Страница 2: ......
Страница 18: ...12 www yoctopuce com...
Страница 26: ...20 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Страница 90: ...84 www yoctopuce com...
Страница 120: ...114 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...21 High level API Reference On failure throws an exception or returns a negative error code 152 www yoctopuce com...
Страница 484: ...478 www yoctopuce com...
Страница 488: ...482 www yoctopuce com...
Страница 490: ...23 Characteristics 484 www yoctopuce com...
Страница 491: ......
Страница 492: ......