Making Serial ports on a Windows PC in C# work with arduino

 This has driven me nuts for 2 days.  I found an obscure note in the corner of the internet that gave me the answer.   To get a serial port on a windows PC  using C# to talk to an arduino.


            myPort = new SerialPort();
            myPort.BaudRate = 9600;
            myPort.PortName = "COM5";
            myPort.Parity = Parity.None;
            myPort.DataBits = 8;
            myPort.StopBits = StopBits.One;
            myPort.Handshake = Handshake.None;
            myPort.RtsEnable = true;
            myPort.DtrEnable = true;
            myPort.Encoding = Encoding.ASCII;

            myPort.ReadTimeout = 550;
            myPort.WriteTimeout = 550;

            myPort.Open();


This right here is the part that NONE of the damned microsoft examples tell you.

            myPort.RtsEnable = true;
            myPort.DtrEnable = true;
            myPort.Encoding = Encoding.ASCII;


After testing I found that a LOT of serial devices need that.

Comments