小编chi*_*oms的帖子

使用蓝牙配合与Arduino UNO和Mac进行串行通信

我正在尝试通过蓝牙在Arduino和Mac之间建立串行通信并遇到问题.

我的环境是这样的:

  • Arduino UNO
  • 来自sparkfun的蓝牙伴侣
  • MacBook,OS X 10.7

首先,我编写了如下所示的arduino,如本教程所示.

/***********************
 Bluetooth test program
***********************/

int counter = 0;
int incomingByte;

void setup() {
  Serial.begin(115200);
}

void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital R, reset the counter
    if (incomingByte == 'R') {
      Serial.println("RESET");
      counter=0;
    }
  }

  Serial.println(counter);
  counter++;

  delay(250);
}
Run Code Online (Sandbox Code Playgroud)

当Arduino连接USB时,它工作得很好.(Arduino控制台接收数字序列,如1,2,3,4 ......带换行符.)

然后我用一些电线连接Arduino UNO和蓝牙伴侣,并成功与Mac配对. …

macos bluetooth arduino serial-communication

5
推荐指数
1
解决办法
3464
查看次数

标签 统计

arduino ×1

bluetooth ×1

macos ×1

serial-communication ×1