我试图通过PC上的“出局”蓝牙端口将数据从C#GUI发送到Teensy 3.2,但没有运气。数据传输的方向相反(将数据从Arduino发送到C#GUI)。我正在使用Putty上的INCOMING蓝牙端口尝试查看“测试字符串”,但没有任何结果。但是,我得到的常量字符串为-1s ????
紧张的代码:
#define HWSERIAL Serial1
void setup() {
HWSERIAL.begin(9600);
}
void loop() {
String command = HWSERIAL.read();
HWSERIAL.print(command);
HWSERIAL.println();
}
C#代码(我基本上只是在重复发送测试字符串):
private void button11_Click(object sender, EventArgs e)
{
portBTSend = new SerialPort("COM24", 9600, Parity.None, 8, StopBits.One);
portBTSend.RtsEnable = true;
portBTSend.DtrEnable = true;
try
{
portBTSend.Open();
}
catch (Exception e1)
{
label8.Text = "Connection to BT Failed. Try Again";
}
while (true) {
portBTSend.Write("TEST STRING");
System.Threading.Thread.Sleep(1000);
}
}