led

Posted https

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了led相关的知识,希望对你有一定的参考价值。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{

public partial class Form1 : Form
{
Byte[] Btn = new Byte[2];

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
serialPort1.PortName = "COM5";
serialPort1.BaudRate = 4800;
serialPort1.Open();
}

private void button1_Click(object sender, EventArgs e)
{

Btn[0] = 0x01;
this.serialPort1.Write(Btn, 0, 1);

}

private void button2_Click(object sender, EventArgs e)
{
Btn[0] = 0x02;
this.serialPort1.Write(Btn, 0, 1);


}

private void button3_Click(object sender, EventArgs e)
{
serialPort1.Close();
Close();
}
}
}

 







































以上是关于led的主要内容,如果未能解决你的问题,请参考以下文章