|
-
Oct 4th, 2010, 03:06 AM
#1
Thread Starter
Fanatic Member
Serial Port Hardware
I've got a 9pin serial port plug and I'm wanting to use a button to play music, seems easy enough except from a hardware point of view, say my standard button has a output wire how do I connect that to my serial port? this video says PIN 1 and 4, but why?
http://www.youtube.com/watch?v=2MlJCMdD8MU
-
Oct 4th, 2010, 11:09 AM
#2
Fanatic Member
Re: Serial Port Hardware
Hi,
You can use one of the serial port inputs to monitor a switch by connecting the switch between an output (I'd use DTR, which defaults to high = True) to an input, such as DCD. So, connect your switch between pins 1 and 4. Open the port (settings don't matter, just specify the PortName, then call Open()). The SerialPort_PinChanged will be generate an event when the switch is opened or closed. For example,
Code:
Private Sub SerialPort_PinChanged(ByVal e As System.IO.Ports.SerialPinChangedEventArgs)
If System.IO.Ports.SerialPinChange.DsrChanged = SerialPinChange.CDChanged Then
If SerialPort.CDHolding = True Then
'switch was closed
ElseIf SerialPort.CDHolding = False Then
'switch was opened
End If
End If
End Sub
Dick
Richard Grier, Consultant, Hard & Software
Microsoft MVP (Visual Basic)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|