【发布时间】:2013-11-26 11:18:45
【问题描述】:
我想将一些数据从我的电脑发送到 PIC 16fxxxx 微控制器。 我用c#写了串口发送器代码:
这里是代码:
try
{
SerialPort port = new SerialPort(
"COM11", 9600, Parity.None, 8, StopBits.One);
// Open the port for communications
port.Open();
////////////////////
byte array1;
array1 = Convert.ToByte("11100100", 2);
/////
byte[] array = new byte[1];
array[0] = array1;
port.Write(array, 0, 1);
// Close the port
port.Close();
}
catch (Exception ed)
{
MessageBox.Show(ed.Message);
}
我的问题是:我测试了该代码并且它成功了,但接收器也是一台 PC。这段代码是否通用:如果我将它连接到 PIC,它会以同样的方式工作吗?
【问题讨论】:
标签: c# serial-port embedded microchip