Visual Studio C# Serial Communication Tutorial – Part 1

43
20



Recommended:
Same video with better audio quality here –

This video tutorial shows how we can access the Serial Port on our computer using Visual Studio C# Windows Forms Application. We can use this to establish serial communication between devices such as micro-controllers. To test the application, I have used an Arduino Uno.

Part 2:

Nguồn:https://wijstaanvooronzegrondrechten.org/

43 COMMENTS

  1. sir, something about seagate hard disk, to work on seagate terminal UART,
    please give me your email,
    my shahzadasalim18@hotmail.com

  2. SIR,, meri english achi nahi hay, mujay lukta hay kay aap URDU/HINDI bool suktay, j
    please,
    mujay aap ka email address day
    shukria

  3. Here is a simple solution to the problem with the program freezing after pressing the read button….
    There is a catch block for the "Timeout Exception", but he forgot to actually set the ReadTimeout attribute of the serial port. To fix this simply add the following:

    serialPort1.ReadTimeout = 2000;

    just before:

    serialPort1.Open();

    (This code is located in the button3_Click event handler

  4. this video is clear and working, but i want to send two values to the arduino simultaneously this time around, and i seem to be struggling with it. can you help me out and maybe send me the arduino code allowing for that to happen or visual studio code

  5. Is it possible can we read and write data on same port?
    I'm asking because after writing a data not able to get acknowledgement DataReceived not fire
    Basically i'm trying to send command to patlite device. You can see the command list from this pdf document(https://drive.google.com/file/d/1ZVIWYLJz28DEeN6-NSsLExEpJI4ZJ4pq/view?usp=sharing)
    For Example:-
    private void PORTOPEN(byte[] data)
    {
    mSerialPort = new SerialPort();
    if (mSerialPort.IsOpen)
    {
    mSerialPort.Close();
    }
    mSerialPort.DataReceived += SerialPort_DataReceived;
    mSerialPort.ErrorReceived += MSerialPort_ErrorReceived;
    mSerialPort.ReadBufferSize = 10240;
    mSerialPort.PortName = "COM5";
    mSerialPort.BaudRate = 9600;
    mSerialPort.StopBits = (StopBits)1;
    mSerialPort.DataBits = 8;
    mSerialPort.Parity = Parity.None;
    //mSerialPort.ReceivedBytesThreshold = 9;
    //mSerialPort.RtsEnable = true;
    mSerialPort.DtrEnable = true;
    mSerialPort.Handshake = Handshake.RequestToSend;
    //mSerialPort.ReadTimeout = 5000;
    //mSerialPort.WriteTimeout = 5000;
    mSerialPort.Open();
    //{ 0x40,0x3F,0x3F,0x4D,0x21 }; // //{ 0x40, 0x35, 0x36, 0x30, 0x32, 0x21 };
    //string s = "@ ?? 1 3 2 !";
    //byte[] data = Encoding.ASCII.GetBytes(s);
    mSerialPort.Write(data, 0, data.Length);
    string read=mSerialPort.ReadExisting();
    }
    private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {

    }
    private void MSerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
    {

    }

  6. I got same project which make serial communication between Arduino and Visual studio C++, full instruction can view at my blog:
    http://engineer2you.blogspot.com/2016/12/arduino-serial-communication-visual.html

  7. Hi
    I am currently work on Gem5 simulation. I configs on bare-metal and need to connect UART to send and receive data from/to My ARM simulated.
    But I confused a bit for script code in Cpp or Pythone for defining UART port . If you have some suggestion or example I would be delightful for me
    thanks

  8. ITS GREAT, ATLEAST I CAN START SOMETHING. CAN I HAVE YOUR HELP MORE. PLZ CONTACT ME IF POSSIBLE.. gkgill_1989@yahoo.com. THX.

  9. Hi Can you make a tutorial delphi c ++ builder or to connect a COM port
    android smartphone and a RECEIVE and transmit data read
    device specifications https://www.youtube.com/watch?v=x48Hk8p-PMo
    & https://www.youtube.com/watch?v=sBYwmE2w9Rk & https://www.youtube.com/watch?v=fpuwOU1rPMU

  10. Hi, can you show how to data from Machine that connected with RS232 can insert into MSFlexGrid or Data Grid that using Ms. Access as a Database ? Thank you with your tutorial.

  11. Hi, I want to write a serial communication between PC and Roboteq controller DC1406 using RS232 and USB adapter, is your tutorial suitable for me to use?

  12. Hi. Thanks for nice tutorial. IS any way to use gridview instead of text box for serial data. I did tried but no luck 🙁

LEAVE A REPLY

Please enter your comment!
Please enter your name here