I'm trying to set up serial communication between Arduino and Mac via Bluetooth and have a problem.
My environment is that:
- Arduino UNO
- Bluetooth Mate from sparkfun
- MacBook, OS X 10.7
First, I programmed arduino like below, as it shown in this tutorial.
/***********************
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);
}
It worked nicely when Arduino was wired with USB. (Arduino console receive the sequence of numbers, like 1, 2, 3, 4... with line breaks.)
Then I connected Arduino UNO and Bluetooth Mate with some wires, and got it successfully paired with Mac.
When I run this line on iTerm, I only received the sequence of question marks.
$ sudo cu -s 115200 -l /dev/tty.name-of-port
Connected.
??????????????????????????????
I also tried screen /dev/tty.name-of-port
, or Arduino console, but the result is the all same.
How can I solve these garbled signals and receive correct chars? Thank you.