Hi all,
I recently purchased a USB experimenter board from Maplin with the idea of linking up to eventGhost so I could make actions happen by pressing a button on my Android phone, something like this…
Android Phone with EventGhost --> Via Internet(DynDNS) --> My EventGhost server @ home --> Trigger Macro to run an Exe --> Turn on D1 on P8055 --> Modified HomeEasy Wireless controller --> mains plug and lights HomeEasy Recievers --> light on, etc…
Having a little VB experience I spent a few days trawling the web and could find no very simple examples I could build upon, also I didn’t want any interactive application, just light on or off… So to this end I’ve listed some extremely simple examples I eventually crafted. These are examples that simply turn on or off a digital output, I’ll get more creative as I go as I’m sure you will…
I used (the free!) Visual Basic 2010 Express…
MS Visual Basic 2010 Express - http://msdn.microsoft.com/en-us/vbasic/default.aspx
EventGhost - http://www.eventghost.org/
HomeEasy Controls - http://www.homeeasy.eu/home.php
Turn Digital Output 1 ON
[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 Sub SetDigitalChannel Lib “k8055d.dll” (ByVal Channel As Integer)
Private Declare Sub ClearDigitalChannel Lib “k8055d.dll” (ByVal Channel As Integer)
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Timer1.Enabled = False
Dim h As Integer
h = OpenDevice(0)
If h = 0 Then
SetDigitalChannel(1)
CloseDevice()
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Close()
End Sub
End Class[/code]
Turn Digital Output 1 OFF
[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 Sub SetDigitalChannel Lib “k8055d.dll” (ByVal Channel As Integer)
Private Declare Sub ClearDigitalChannel Lib “k8055d.dll” (ByVal Channel As Integer)
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Timer1.Enabled = False
Dim h As Integer
h = OpenDevice(0)
If h = 0 Then
ClearDigitalChannel(1)
CloseDevice()
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Close()
End Sub
End Class[/code]
I’m sure there are gurus who will point at some obvious mistakes and I stand happy to be corrected/modified.
If you have any very simple VB examples that you would be willing to share I’m sure this thread will happily recieve them…