I didn't want to use the default TextBox1,ComboBox1 naming convention as it was quite confusing. I have used Two ComboBox Controls to set the Serial port settings (Port Name and Baud rate).Ī " Transmit " Button together with TextBox to sent data to Arduino or any other Microcontroller which is grouped under a " Serial Transmit" GroupBox.Ī " Receive Data " Button together with " Received Data " TextBox to receive data from Arduino or any other Microcontroller which is grouped under a " Serial Receive" GroupBox.Ī " Log " TextBox to Display additional information to the user.īelow Figure shows the Name associated with each control on my Form. Next thing is to populate your Form with various controls like Buttons,ComboBoxes,TextBoxes etc using the Design View in Visual Studio.
You can access the Form1.cs code file by double clicking on Form1 in Design View. įirst thing to do is to add the System.IO.Ports namespace to the top of your code so that you can use the SerialPort Class in your program. Now here I am only going to explain how my Form1 is arranged and what are code snippets that make it tick.All of the code that makes the program is inside the Form1 partial class. If you are new to serial port programming using C# ,I would recommend that you check my previous tutorial before starting.The IDE used here for building the program is Visual Studio 2015 Community Edition which can be freely downloaded from the web.įirst thing to do is to create a Windows Form Project using the " New -> Project " Option on Visual Studio which would add all the required references for your Project.If you are creating an Empty Project you will have to add all those references manually (references to ,System.Drawing etc).Īfter you have created the project you can use the designer to Create your own Serial Communication program by adding and rearranging the controls on your Form1. You can download the prebuilt windows executable (.exe) from below.
You can also download the entire code files as Zip archive . The C# source codes used in this tutorial along with the Arduino Uno codes are available on our Github Repository.
The Program will be able to transmit and receive few strings to Arduino and blink the LED's connected pin13 of Arduino Uno. In this tutorial we will build a GUI based Serial port Communication program using C# and Visual Studio Community edition.Here we will combine both the transmission and reception parts into a single Windows Form based program that will communicate with an Arduino Uno.
In the previous one ,I explained how to open,close,read and write to a serial port using simple command line programs. This is my Second Tutorial on programming the serial port using C# and dotnet framework.