Serial Port Communication in C#




The serial port of the PC is a very important resource both in industrial environment and in home-made electronics, due to the wide popularity of the UART interface which is to be found on many microcontrollers or on many test and design instrumentation (programmable power supplies, multi-meters, oscilloscopes etc). Even if modern-day computers tend not to have a physical serial port anymore, this obstacle is overcome by the appearance on the market of USB to UART converters (like the FTDI chips for example) which can emulate serial ports. Thus, from a computer application point of view, writing to such a device is as easy as writing to a regular serial port.

Serial Port Communication in C#

1. Introduction

The serial port is a serial communication interface through which information transfers in or out one bit at a time.  This article will show how it is possible to build such an application using the C# environment. It is not intended to be a C# tutorial, but to teach a user who has basic knowledge of C or C# to integrate serial port control in one of his applications. A development environment which includes a C# compiler should be used. There are many open source IDE which takes up very little space on your hard drive and can be a good alternative to users who do not want to install the gigabytes of Visual Studio on their PCs for a simple serial port application.

2. Code Design

To be able to use “SerialPort” component is need to add at the beginning of your code the directive for using the System.IO.Ports namespace, as this is not added by default when you create the solution:

For more detail:  Serial Port Communication in C#




Leave a Comment

*
= 4 + 0

Read previous post:
Temperature Alarm
A PIC-Based Temperature Alarm using PIC16C84

Presented is a simple temperature alarm which uses a PIC16C84 microcontroller and a 2-line LCD display. The alarm displays current...

Close
Scroll to top