title: Sending fixed voltage to serial port
body: <p>I need to monitor if a door is opened. I have a sensor that continues to generate +5V DC as long as the door is shut but drops down to 0V once the door is opened.</p>
  
  <p>I now need to connect the sensor's output wire to PC's serial port and write a program that continuously polls the port.</p>
  
  <p>My thought is that various serial-io parameters such as baud rate, etc., does not matter in my case. For each byte that I read, I expect the value to be 255 (logical 1s) when the door is closed. Otherwise, I will assume that the door has been opened. Is there any flaw in this logic?</p>
  
  <p>I went through <a href="https://stackoverflow.com/questions/5226580/sending-a-voltage-to-rs232">Sending a voltage to RS232</a>. It appears I just need to connect the wire to pin 2 (RX). However, for the serial port to receive a logical 1, it seems the voltage needs to be between -3V and -12V. As the voltage my sensor generates is positive, I am thinking I will connect the sensor wire to pin 5 (GND) instead and connect pin 2 to ground. In effect, I inverted the voltage. Will this work?</p>
  
  <p>If this logic is flawed, I may have to buy a voltage inverter. </p>
  
  <p>Finally, I was told that one should not connect anything to pin 5 on a motherboard's serial port. Apparently, it is hardwired to get grounded to the chassis. Is this true? Regards.</p>