Riley
03-28-2007, 06:39 PM
How do I open the Interface Kit without activating all of the outputs upon Attach? I am using a Touch Sensor to activate a video greeting and a door bell. The doorbell goes off upon start up, and the sensor (or GUI button) must be activated in order to turn it off.
Thanks for an suggestions!
Riley
The offending code if it helps:
Public Class Form1
Dim WithEvents IFKit As New Phidgets.InterfaceKit
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = "Sensor Activated: ? "
Label2.Text = "Status: Not Connected"
Label3.Text = "Serial Number: "
IFKit.open()
End Sub
Private Sub IFKit_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles IFKit.Attach
Label2.Text = "Status: Connected"
Label3.Text = "Serial Number: " & IFKit.SerialNumber
End Sub
Private Sub IFKit_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles IFKit.Detach
'Subroutine called when the Phidget is detached from the computer
Label2.Text = "Status: Not Connected"
Label3.Text = "Serial Number: "
End Sub
Private Sub IFKit_Error(ByVal sender As Object, ByVal e As Phidgets.Events.ErrorEventArgs) Handles IFKit.Error
'A subroutine that deals with error conditions
MessageBox.Show(e.Description)
'Show the error that has occurred
Me.Close()
'Close the program
End Sub
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
'"Close" button closes program
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'The subroutine that is run as the program closes
IFKit.outputs(5) = False
IFKit.close()
'This block of code ensures that the Phidget is disabled.
'It is not strictly necessary but recommended
End Sub
Private Sub Sensor1_Touch(ByVal sender As System.Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles IFKit.SensorChange
IFKit.outputs(5) = e.Value < 500
Label5.Text = "Sensor Working: Yes!"
'Activate IFKit Digital Output 1
'when value is below 500
'The range of the Phidget Touch Sensor is 0-1000
'so this will automatically reset the Digital Output to off
'when the Phidget Touch Sensor is no longer being touched
End Sub
Private Sub Sensor2_Touch(ByVal sender As System.Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles IFKit.SensorChange
Dim prc As New Process
prc.StartInfo.FileName = "C:\movies\1.avi"
prc.StartInfo.Arguments.Insert(0, "-Fullscreen")
prc.Start()
End Sub
Public Sub Sensor3_Touch(ByVal sender As System.Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles IFKit.SensorChange
If IFKit.outputs(5) = e.Value < 500 Then
IFKit.outputs(5) = True
End If
End Sub
Public Sub Sensor4_Touch(ByVal sender As System.Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles IFKit.SensorChange
If IFKit.outputs(5) = e.Value > 500 Then
IFKit.outputs(5) = False
End If
End Sub
Private Sub Button1_Down(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
IFKit.outputs(5) = True
Label1.Text = "Output Activated: Yes! "
'This causes Button1 to activate IFKit Digital Output 5
End Sub
Private Sub Button1_Up(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
IFKit.outputs(5) = False
Label1.Text = "Output Activated: No! "
'This causes Button1 to deactivate IFKit Digital Output 5
End Sub
End Class
Thanks for an suggestions!
Riley
The offending code if it helps:
Public Class Form1
Dim WithEvents IFKit As New Phidgets.InterfaceKit
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = "Sensor Activated: ? "
Label2.Text = "Status: Not Connected"
Label3.Text = "Serial Number: "
IFKit.open()
End Sub
Private Sub IFKit_Attach(ByVal sender As Object, ByVal e As Phidgets.Events.AttachEventArgs) Handles IFKit.Attach
Label2.Text = "Status: Connected"
Label3.Text = "Serial Number: " & IFKit.SerialNumber
End Sub
Private Sub IFKit_Detach(ByVal sender As Object, ByVal e As Phidgets.Events.DetachEventArgs) Handles IFKit.Detach
'Subroutine called when the Phidget is detached from the computer
Label2.Text = "Status: Not Connected"
Label3.Text = "Serial Number: "
End Sub
Private Sub IFKit_Error(ByVal sender As Object, ByVal e As Phidgets.Events.ErrorEventArgs) Handles IFKit.Error
'A subroutine that deals with error conditions
MessageBox.Show(e.Description)
'Show the error that has occurred
Me.Close()
'Close the program
End Sub
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
'"Close" button closes program
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'The subroutine that is run as the program closes
IFKit.outputs(5) = False
IFKit.close()
'This block of code ensures that the Phidget is disabled.
'It is not strictly necessary but recommended
End Sub
Private Sub Sensor1_Touch(ByVal sender As System.Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles IFKit.SensorChange
IFKit.outputs(5) = e.Value < 500
Label5.Text = "Sensor Working: Yes!"
'Activate IFKit Digital Output 1
'when value is below 500
'The range of the Phidget Touch Sensor is 0-1000
'so this will automatically reset the Digital Output to off
'when the Phidget Touch Sensor is no longer being touched
End Sub
Private Sub Sensor2_Touch(ByVal sender As System.Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles IFKit.SensorChange
Dim prc As New Process
prc.StartInfo.FileName = "C:\movies\1.avi"
prc.StartInfo.Arguments.Insert(0, "-Fullscreen")
prc.Start()
End Sub
Public Sub Sensor3_Touch(ByVal sender As System.Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles IFKit.SensorChange
If IFKit.outputs(5) = e.Value < 500 Then
IFKit.outputs(5) = True
End If
End Sub
Public Sub Sensor4_Touch(ByVal sender As System.Object, ByVal e As Phidgets.Events.SensorChangeEventArgs) Handles IFKit.SensorChange
If IFKit.outputs(5) = e.Value > 500 Then
IFKit.outputs(5) = False
End If
End Sub
Private Sub Button1_Down(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
IFKit.outputs(5) = True
Label1.Text = "Output Activated: Yes! "
'This causes Button1 to activate IFKit Digital Output 5
End Sub
Private Sub Button1_Up(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
IFKit.outputs(5) = False
Label1.Text = "Output Activated: No! "
'This causes Button1 to deactivate IFKit Digital Output 5
End Sub
End Class