VisionBox .NET Library
Led_Example.vb

Visual Basic example for using the Led device

1 Public Class Led_Example
2  Public Shared Sub Led()
3  Console.Clear()
4  'acquire a new factory
5  Dim pVIBSystem As VIB_NET.VIBSystem = New VIB_NET.VIBSystem()
6 
7  If pVIBSystem IsNot Nothing Then
8  Try
9  'open device: Led number 0
10  Dim pLed As VIB_NET.Led = DirectCast(pVIBSystem.OpenDevice(VIB_NET.eDEVICE_TYPE.LED, 0), VIB_NET.Led)
11 
12  Console.WriteLine("I'm a " + pLed.GetType().ToString() + ".")
13 
14  If pLed IsNot Nothing Then
15  Try
16  'Set Led 1 ON and all other OFF
17  pLed.Set(2, 255)
18  'Set all Leds OFF
19  pLed.Set(0, 255)
20  'Set all available Leds Step by Step ON and OFF again
21  For i As UInt32 = 0 To pLed.NumberOfLEDs - 1 Step 1
22  pLed.SetLED(i, True)
23  System.Threading.Thread.Sleep(500)
24  pLed.SetLED(i, False)
25  Next
26 
27  'Set Led mode for Led 0 to ON
28  pLed.SetMode(0, VIB_NET.Led.eLED_MODE.GEN0)
29 
30  'Set Led mode for Led 2 to OFF
31  pLed.SetMode(2, VIB_NET.Led.eLED_MODE.GEN1)
32 
33  'signal with 300 ms on and 1500 ms off
34  pLed.ConfigureGenerator(0, 1, 300, 0, 1500)
35 
36  'two pulses(200 ms on, 100 ms off) 500 ms break time(LED off), two pulses ...
37  pLed.ConfigureGenerator(1, 2, 200, 100, 500)
38  Catch e As System.Exception
39  Console.WriteLine(e.Message)
40  Finally
41  'close device
42  pVIBSystem.CloseDevice(pLed)
43  pLed = Nothing
44  End Try
45  End If
46  Catch e As System.Exception
47  Console.WriteLine(e.Message)
48  Finally
49  'release factory
50  pVIBSystem = Nothing
51  End Try
52  End If
53  Console.WriteLine(vbNewLine + "Press enter to proceed...")
54  System.Console.ReadLine()
55  End Sub
56 End Class