وهذا هو كود السى شارب
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int address, int value);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 9600;
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;
//serialPort1.DtrEnable = Enabled;
//serialPort1.RtsEnable = Enabled;
serialPort1.Open();
if (!serialPort1.IsOpen)
textBox1.AppendText("COM1 cannot be opened");
serialPort1.Write("10101010");
serialPort1.Close();
}
}
}