I recently purchased the k8055 to try to learn how to utilize it to control various components. The k8055 works great with the demo software. I studied the source a little to try to learn how to connect to the board. I think I’m close but not getting the intended results. Any advice on the code below would be appreciated…
[code]Public Class Form1
Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
Private Declare Sub CloseDevice Lib "k8055d.dll" ()
Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Integer
Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (ByRef Data1 As Integer, ByRef Data2 As Integer)
Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer, ByVal Data As Integer)
Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Integer, ByVal Data2 As Integer)
Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Integer)
Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Boolean
Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Integer
Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Integer) As Integer
Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Integer)
Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Integer, ByVal DebounceTime As Integer)
'Public up, down, lleft, rright As Boolean 'to keep track of which buttons are already pressed
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CardAddress As Integer
Dim h As Integer
CardAddress = 3
h = OpenDevice(CardAddress)
Label1.Text = "Card " + Str(h) + "connected"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SetAllDigital()
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.A : SetDigitalChannel(8) : Label5.ForeColor = Color.Red
Case Keys.L : SetDigitalChannel(4) : Label4.ForeColor = Color.Red
Case Keys.Z : SetDigitalChannel(6) : Label2.ForeColor = Color.Red
Case Keys.K : SetDigitalChannel(2) : Label3.ForeColor = Color.Red
End Select
End Sub
Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
Select Case e.KeyCode
Case Keys.A : ClearDigitalChannel(8) : Label5.ForeColor = Color.Black
Case Keys.L : ClearDigitalChannel(4) : Label4.ForeColor = Color.Black
Case Keys.Z : ClearDigitalChannel(6) : Label2.ForeColor = Color.Black
Case Keys.K : ClearDigitalChannel(2) : Label3.ForeColor = Color.Black
End Select
End Sub
End Class[/code]