Basic Computer Programming Pdf
Yes, essentially you open a serial port device with a special name, such as COM1, and read and write to it much as you would a file. The pins used will (naturally) be the serial transmit and receive pins.If you want to control specific pins but not necessarily in a serial way, you might be better off working with a parallel port instead. The parallel port voltages are usually more friendly to TTL level logic and can often be driven directly.Update: If you just need to toggle one pin as per your comment, you may be able to use the DTR line for this. See the function documentation for how to do this.
Serial Port Communication
@user318811: Greg's right: for anything like this, you almost certainly want to use the parallel port. The pins on the serial port are driven almost entirely by the UART, and it does so mostly under a clock, so it's generally impossible to hold a line in a given state for longer than a given period of time (basically, the time to transmit one byte at whatever speed you pick). You can slow the serial port down (e.g., to 300 baud) to get it to hold a state longer, but that will also limit the maximum transition rate (e.g., to 300/second).–Mar 26 '11 at 4:16.