Trapping input from COM2

I'm trying to make a motion detector that plugs into COM2.
What I'm planining to do is to make a bulb/laser shine onto an LDR. When someone breaks the line, this would break the circuit.
How could I trap the response from the COM port, and which pins wouldI need to use?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan RowleyCommented:
Pins 2, 3 and a ground.
The com ports are digital communication devices.
It would seem to me to do this correctly you would need a
ADC in between the motion detector and the com port.

To read info from the port you can use redirection or a terminal program to just get a reaction. To get a meaning full response I think you would have to write a program that reads the port and does some interpretations.

I wouldn't reccommend just hooking your device directly to the com port. You have certain voltage and other power requirements to concider.
Ryan RowleyCommented:
I would also design some Optical Isolation into your circuit. You want to protect your com port from damage.
Actually, I only partially agree with highstar1 .
Pins 2,3 are transmit and receive. I would NOT use these, since you are not sending over serail data. All you want is a single make/break/detect.
For this I would use the handshake lines on the serial port.

CTS, RTS lines are te best.
see :

I hope this helps !
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

For More info see :
Ryan RowleyCommented:
There are quite a few pin combinations you can use.
2 and 3 will work with redirection CTS/RTS needs to be read differently. Your selections grow if you are using a 25 pin serial port opposed to a nine pin. There is alot of unused functionality in the serial ports. However it is all digital with specific voltage levels (0,1).
RS232 ports have their limit. If I'm remembering correctly
the ??RS452?? ports are designed for sensors and digital analog device control.
"When someone breaks the line, this would break the circuit."

If you use a strong enough laser, you don't need to worry about triggering an alarm via com port.
Ryan RowleyCommented:
There are quite a few pin combinations you can use.
2 and 3 will work with redirection CTS/RTS needs to be read differently. Your selections grow if you are using a 25 pin serial port opposed to a nine pin. There is alot of unused functionality in the serial ports. However it is all digital with specific voltage levels (0,1).
RS232 ports have their limit. If I'm remembering correctly
the ??RS452?? ports are designed for sensors and digital analog device control.
Ryan RowleyCommented:
Magarity: LOL :)

Cut them down to size. :)
The pin connections for an AT style 9 pin serial port are:

1  Data Carrier Detect (DCD)
2  Receive Data (Rxd or Rx)
3  Transmit Data (Txd or Tx)
4  Data Terminal Ready (DTR)
5  Signal Ground (Grd)
6  Data Set Ready (DSR)
7  Request To Send (RTS)
8  Clear To Send (CTS)
9  Ring Indicator

You only need two lines one of which is the signal ground and the other you can select one of the handshake lines. It will be necessary to use an operational amplifier to act as a buffer or step down the voltage or change the polarity of the voltage.

The addresses for the serial ports are:

COM1  03F8 - 03FF  which is usually used for the mouse.
COM2  02F8 - 02FF  Usually used for the modem
COM3  03E8 - 03EF
COM4  02E8 - 02EF

Suppose you have selected to use com2 and the INS 8250 UART is used in your computer.

To turn any of the lines ON or OFF it will be best to create a .com or a .exe file using DEBUG (DOS File) or an assembler program such as MASM.

To activate the say DTR line you must set bit number 0 of the address 02FC to logic 1

eg.  mov  dx,02FC
     mov  al,01
     out  dx,al

to turn it off bit 0 at the address 02FC must be set to 0
such as mov al,00.  
Similarly the following handshake lines are in the address 02FE
CTS is data bit No. 4   -  10 in hex
DSR is bit No. 5        -  20
RI  is bit 6            -  40
DCD is data bit no.7    -  80

It may be necessary to take the output of your device back to the computer via a buffer to pin2 (Rxd) to monitor it.

Good Luck  
sierrahalflifeAuthor Commented:
Thanks for all your suggestions... To clarify from my end, I was thinking about having the LDR on the serial line, but powering the laser from a different source.
I only want to know when someone breaks it and set off an alarm... If I cut them in half, they'll never leave!

Am I right to asume that you are a College student and you need help for your project?
The Light Dependent Resistor(LDR)will have to be used in a comparator circuit.  You supply the comparator from a +V to the Ground. You connect one end of the LDR to Grd and the other end (say point A) in series with a fixed value resistor and a preset resistor (for fine adjustment)to the +V.  Connect point A through say a 10 kohm resistor to the inverting input of the comparator.  Connect 2 10kohm resistors in series across the +V and Gnd to form a Wheatstone bridge.  Connect the point between these two equal value resistors (say point B) through a 10 kohm resistor to the non-inverting input of the comparator. Point B should be at half the supply voltage.  If the voltage at A is less than the voltage at point B, the output of the comparator is at the Gnd potential.  This occurs when the light shines onto the LDR and its resistance is low.  If the light beam is broken the voltage at point A should be slightly higher than the voltage at B so that the output of the comparator switches to the +V. The output can be connected in series with a resistor to the base of a transistor biased to operate as a switch which in turn switches on a bell or a sirene.  (Speakers require an oscillator to operate).  If you want the bell to continue ringing well after the beam of light is restored you will need to use a thyristor as a switch instead of a transistor.  You may also have to incorporate a timer in the circuit in order to switch off the alarm after 15 minutes I believe, otherwise you will be breaking the Law.  To switch it off you will need to connect a switching device (transistor or relay etc) in series with the anode or cathode of the thyristor.  The voltage for the input of the comparator can be switched on by a transistor preferably a mosfet switched on by the serial port of your computer. Unfortunately I cannot draw the circuit diagram here for you.
sierrahalflifeAuthor Commented:
I am a college student, but this is for an own-gratification project, not a college one.
I was thinking of routing it through through the PC so I can easily implement a timer into it, or a password-override to get it to shut up
sierrahalflifeAuthor Commented:
And, I can be mailed at: or if needed
I cannot really sent you a diagram because I usually draw my circuit diagrams on a mac using Claris Works and unfortunately the modem on that computer needs replacing,  You should be able to draw the diagram from the above discription.  You can use the CA3140 op.Amp as a comparator which has the same pin configuration as the 741 op. amp.  The CA3140 type is based on JFET type transistors which are voltage operated while the 741 is a current operated based on bi-polar technology.  You can also use an LM311 as a comparator.  The pin configuration of the CA3140 op. amplifier are:-
Pin 1 zero offset  - Not connected if used as a comparator.
Pin 2 Inverting Input
Pin 3 Non-inverting Input
Pin 4 -V  -  This pin is connected directly to the ground or the zero volt line.
Pin 5 Zero offset - not required for this application.
Pin 6 is the output. - Connect through a resistor to the  base or gate of a transistor depending on the type of transistor used, or to the gate of the thyristor if you decide to use a thyristor to switch on the alarm.
Pin 7 is connected to a +12 volt supply.
Pin 8 is not used.  
Component suppliers such as MAPLINS, Radio Spares, and Farnell, often provide data and circuit diagrams including RS232c circuits.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sierrahalflifeAuthor Commented:
Thanks. I'll look into getting the components. Will all I need be an RS232 connector, the opamp, an ldr, a laser-pen and wiring?
One more thing.  If you use an LDR and a light source, the LDR must be enclosed in a tube to prevent it operating from other light sources, and also the light source must produce a beam directed straight to the LDR.  The light beam will be clearly vissible and it will be no good for use as an intruder alarm.  It can be used for checking the height or counting components on a convayor for example. You could use an infra red detector and an infra red transmitter instead.

Good luck
sierrahalflifeAuthor Commented:
With a laser pen, you only see the beam if it's dusty/smoky
Well done.  If you are happy with the answer to your question, then you must accept an answer.

Goodbye from me
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link 
POINTS FOR EXPERTS awaiting comments are listed in the link below
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moderator @ Experts Exchange
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.