playing with firecrackers

Well, I’ve been playing with my firecracker today (keep your jokes to yourself) and I have to say it’s pretty cool. I grabbed an X10 library dll from Brian Vallelunga’s site: here

The code below took about 5 minutes to write and now I can control the two modules that came with the firecracker just by clicking on a form button.

Next step, speech control…

 

Imports Vallelunga.X10
Public Class Form1
   Private DeviceID As Integer

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      RadioButton1.Checked = True
   End Sub
   Private Sub LampON(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
      SendSignal(CM17ACommand.TurnOn)
   End Sub
   Private Sub LampOFF(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
      SendSignal(CM17ACommand.TurnOff)
   End Sub
   Private Sub ItemSelect(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged, RadioButton2.CheckedChanged
      If sender.Equals(RadioButton1) Then
         DeviceID = 2
      ElseIf sender.Equals(RadioButton1) Then
         DeviceID = 3
      End If
   End Sub


   Private Sub SendSignal(ByVal command As CM17ACommand)
      Dim firecracker As CM17A = CM17A.Instance("COM1")
      firecracker.SendCommand(HouseCode.B, DeviceID, command)
      firecracker.Dispose()
   End Sub
End Class

Tinggalkan komentar