C:\> Rostislav Persion's Projects

.:: Arduino C# Serial Com ::.
Communicating with Arduino using C#




This is a very simple C# console application that reads serial data from an Arduino using USB serial communication.

SOFTWARE WRITTEN IN C#
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.IO.Ports;
  using System.Threading;
   
  namespace Serial1
  {
      class Program
      {
          static void Main(string[] args)
          {
              SerialPort sp1 = new SerialPort("COM4", 9600);
              sp1.Open();
   
              while(true)
              {
   
                  string val = sp1.ReadLine();
                  Console.WriteLine(val);
   
              }
   
              sp1.Close();
   
   
          }
      }
  }