Contrôle De La Partie Module - Yoctopuce Yocto-I2C Mode D'emploi

Table des Matières

Publicité

18. Utilisation du Yocto-I2C en VisualBasic .NET
target
= i2cPort.get_module().get_serialNumber()
End If
i2cPort
=
YI2cPort.FindI2cPort(target
If (i2cPort.isOnline()) Then
i2cPort.set_i2cMode("400kbps")
i2cPort.set_i2cVoltageLevel(YI2cPort.I2CVOLTAGELEVEL_3V3)
i2cPort.reset()
REM do not
forget
REM of
the Yocto-I2C
Console.WriteLine("****************************")
Console.WriteLine("* make sure voltage levels
Console.WriteLine("* are properly configured
Console.WriteLine("****************************")
Dim
toSend
As List(Of Integer) = New List(Of Integer)
Dim
received
Dim
tempReg
If
((tempReg
tempReg
=
Else
tempReg
=
End If
Console.WriteLine("Ambiant temperature: "
16.0)))
Else
Console.WriteLine("Module not connected (check identification and USB
End If
REM
wait
5
sec
System.Threading.Thread.Sleep(5000)
YAPI.FreeAPI()
End Sub
End Module
18.4. Contrôle de la partie module
Chaque module peut-être contrôlé d'une manière similaire, vous trouverez ci dessous un simple
programme d'exemple affichant les principaux paramètres d'un module et permettant d'activer la
balise de localisation.
Imports
System.IO
Imports
System.Environment
Module
Module1
Sub usage()
Console.WriteLine("usage: demo <serial or logical name>
End
End Sub
Sub Main()
Dim argv() As
Dim
errmsg
As
Dim
m
As
ymodule
If
(YAPI.RegisterHub("usb",
Console.WriteLine("RegisterHub error:"
End
End If
If
argv.Length
m
= YModule.FindModule(argv(1)) REM
If (m.isOnline()) Then
If
argv.Length
If argv(2) =
If argv(2) =
End If
Console.WriteLine("serial:
148
to
configure the powerOutput
as
well
if
used
As List(Of Integer) =
As
Integer
= (received(0) << 8) + received(1)
And &H1000) <> 0) Then
tempReg
-
&H2000
REM
tempReg
And
&HFFF
REM
to
show the output
String
= System.Environment.GetCommandLineArgs()
String
=
""
errmsg) <> YAPI_SUCCESS) Then
<
2
Then usage()
>
2
Then
"ON"
Then m.set_beacon(Y_BEACON_ON)
"OFF"
Then m.set_beacon(Y_BEACON_OFF)
+ ".i2cPort")
and
*")
*")
i2cPort.i2cSendAndReceiveArray(&H1F, toSend,
perform sign extension
clear status bits
+
String.Format("{0:0.000}", (tempReg
+ errmsg)
use serial
or
logical name
"
+ m.get_serialNumber())
From
{&H5}
cable)")
[ON/OFF]")
www.yoctopuce.com
2)
/

Publicité

Table des Matières
loading

Table des Matières