Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // OrtizOL - xCSw - http://ortizol.blogspot.com
  2.  
  3. using System;
  4. using System.IO.Ports;
  5.  
  6. namespace Receta.CSharp.R0520
  7. {
  8.     public class EscrituraEnCom1
  9.     {
  10.         public static void Main()
  11.         {
  12.             Console.WriteLine(Environment.NewLine);
  13.            
  14.             // Creación de instancia `SerialPort`:
  15.             using( SerialPort puerto = new SerialPort("COM1"))
  16.             {
  17.                 // Propiedades del puerto COM1:
  18.                 puerto.BaudRate = 9600;
  19.                 puerto.Parity = Parity.None;
  20.                 puerto.ReadTimeout = 10;
  21.                 puerto.StopBits = StopBits.One;
  22.                
  23.                 // Escribe cadena de caracteres en el puerto:
  24.                 puerto.Open();
  25.                 puerto.Write("Blog xCSw");
  26.                
  27.                 Console.WriteLine("Se ha escrito en el puerto COM1.");
  28.             }
  29.            
  30.             Console.WriteLine(Environment.NewLine);
  31.         }
  32.     }
  33. }