Set up serial port and write string to it : COM Port SerialPort « Development « C# / CSharp Tutorial






using System;
using System.IO.Ports;

static class MainClass
{
    static void Main(string[] args)
    {
        using (SerialPort port = new SerialPort("COM1"))
        {
            // Set the properties.
            port.BaudRate = 9600;
            port.Parity = Parity.None;
            port.ReadTimeout = 10;
            port.StopBits = StopBits.One;

            // Write a message into the port.
            port.Open();
            port.Write("Hello world!");

            Console.WriteLine("Wrote to the port.");
        }
    }
}








14.32.COM Port SerialPort
14.32.1.Open Serial port and read
14.32.2.Set up serial port and write string to it