基于单片机串口通信的上位机和下位机首先亮出C#的源程序吧
主要界面:只是作为简单的运用,可以扩展的
源代码:using System;using System
Collections
Generic;using System
ComponentModel;using System
Data;using System
Drawing;using System
Text;using System
Windows
Forms;using System
Ports;using System
Timers;namespace 单片机功能控制{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } SerialPort sp = new SerialPort(); private void button1_Click(object sender, EventArgs e) { String str1 = comboBox1
Text;//串口号 String str2 = comboBox2
Text;//波特率 String str3 = comboBox3
Text;//校验位 String str4 = comboBox5
Text;//停止位 String str5 = comboBox4
Text;//数据位 Int32 int2 = Convert
ToInt32(str2);//将字符串转为整型 Int32 int5 = Convert
ToInt32(str5);//将字符串转为整型 groupBox3
Enabled = true;//LED控制界面变可选 try { if (button1
Text == "打开串口") { if (str1 == null)