using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO.Ports; namespace led { public partial class Form1 : Form { SerialPort sp = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { sp.Open(); sp.Write("A"); sp.Close(); } private void button2_Click(object sender, EventArgs e) { sp.Open(); sp.Write("B"); sp.Close(); } } }