Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need to add a push button to my computer (no parellel port:(

Status
Not open for further replies.

trend

Member level 5
Joined
Dec 14, 2004
Messages
86
Helped
7
Reputation
14
Reaction score
2
Trophy points
1,288
Activity points
1,104
Hey, I need to add a button to my computer that I can access programatically (pref vb.net)

I usually would use the parellel port, but this computer doesn't have one.. Nor can I add one (for other reasons)

It does have a serial port, usb, audio ports.

Interrupt driven is preferable. But how can I do this?


thanks

Added after 35 minutes:

Could I utilize serial ports pin 9 "Ring Indicator" ? that pin and ground the other side?
 

Re: Need to add a push button to my computer (no parellel po

hi,

you can use the serial port " data carrier detect " pin 1 of 9.

the switch should toggle between GND and VCC.

1. Start a new instance of Visual Basic.
2. Create a new Standard EXE project. Form1 is created by default.
3. Choose Components from the Project menu, check the "Microsoft Comm Control," and click OK.
4. Add an MSCOMM control to the form.
6. Add the following code to Form1's code window:


Private Sub Form_Load()
Form1.Caption = "App2"
With MSComm1
.CommPort = 2
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
.PortOpen = True
' Leave all other settings as default values.
End With
End Sub

Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub

Private Sub MSComm1_OnComm()
if MSComm1.CommEvent=comEvDSR then
msgbox "button pressed"
end if
end sub



check here:

https://support.microsoft.com/default.aspx?scid=kb;en-us;194922


good luck
Ran
 

    trend

    Points: 2
    Helpful Answer Positive Rating
I <3 you :) hah. So I need a push button with 3 contacts, right?

thanks again!
 

Re: Need to add a push button to my computer (no parellel po

right, the common you connect to the "data carrier detect " pin and the two other to VCC and GND.

Ran
 

    trend

    Points: 2
    Helpful Answer Positive Rating
You can develop a small microcontroller based product which will talk to PC over RS-232 port. You can connect switches to microcontroller's input ports and write a software to communicate there status to the PC.

Actully it will be little expensive solution but you can do lot of other things using the same circuit like adding LCD Display etc.
 

Re: Need to add a push button to my computer (no parellel po

trend said:
I <3 you :) hah. So I need a push button with 3 contacts, right?

thanks again!
You don't need a SPDT (3 contact) switch. A SPST (2 contact) switch will do just fine. Connect one side of the switch to ground. Connect the other side to the serial port pin AND to a resistor (2 K will do). Connect the other side of the resistor to Vcc.

You can actually use other pins on the serial port for power. If you set RTS high, you can use that pin for +12. Generally ground is ok for the low signal, but if not set one of the serial control signals to -12 and use that pin.
 

    trend

    Points: 2
    Helpful Answer Positive Rating
Thanks guys..

I don't mind putting a resistor on a single one.. but might be doing many of these.. So if I use a 3 contact (SPDT), will I have to use a contact ? I am guessing, yes oneither.. but just checking..
thanks!
 

Re: Need to add a push button to my computer (no parellel po

I don't quite understand your question.
If you use a spdt (3 contact) you will have to connect 3 wires (no resistor).
If you use a spst (2 contact) you will have to connect 2 wire (one with a resistor in series).
 

Re: Need to add a push button to my computer (no parellel po

hi trend,

as you can see in the link:

https://en.wikipedia.org/wiki/Switch

the SPDT as 3 lines.

you need to connect the Com to pin 1 of 9 (carier detect)
you need to connect the L1 to pin 5 of 9 (Ground)
you need to connect the L2 to pin 7 of 9 (will used as VCC)

in order to use pin 7 as VCC you will need to add the next line:

mscomm1 .RTSEnable=true

at stady state the com is conncted to the L1-GND (pin 5) . when you press the switch the com is connected to L2-VCC(pin 7). then the visual basic will recognize change and will go to the function.

you don't need to add any resistors.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top