Serial communication with Arduino UNO and Mac using bluetooth mate

I am trying to set up serial communication between Arduino and Mac via Bluetooth and the problem.

My environment is this:

  • Arduino uno
  • Sparkfun Bluetooth Mate
  • MacBook, OS X 10.7

First I programmed arduino as shown below, as shown in this tutorial .

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

int counter = 0;
int incomingByte;

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

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

  Serial.println(counter);
  counter++;

  delay(250);
}

This worked well when the Arduino was connected to USB. (The Arduino console accepts a sequence of numbers, such as 1, 2, 3, 4 ... with line breaks.)

Then I connected the Arduino UNO and Bluetooth Mate with some wires and got it successfully paired with a Mac.

When I run this line on iTerm, I get only a sequence of question marks.

$ sudo cu -s 115200 -l /dev/tty.name-of-port
Connected.
??????????????????????????????

I also tried screen /dev/tty.name-of-porteither the Arduino console, but the result is still the same.

? .

+5
1

, - . 9600. , 115200 .

0

All Articles