using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace DTR1060330_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 9600;
serialPort1.Parity = Parity.None;
serialPort1.DataBits = 8;
serialPort1.StopBits = StopBits.One;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
button2.Enabled = true;
button3.Enabled = true;
button4.Enabled = true;
serialPort1.Open();
}
private void button3_Click(object sender, EventArgs e)
{
serialPort1.DtrEnable = true;
button3.Enabled = false;
button4.Enabled = true;
}
private void button4_Click(object sender, EventArgs e)
{
serialPort1.DtrEnable = false;
button4.Enabled = false;
button3.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
button1.Enabled = true;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
serialPort1.Close();
}
}
}
沒有留言:
張貼留言