You Reply: Thanks for the quick replies!
Lauren:
I'm using 115200 baud rate at both sides.
I have the v1.0 version Romeo, so there is no jumper to switch.
Bluetooth module color is black, so apparently v3
My code now prints the number of characters that the PC sent to it, when a button is pressed.
[code]
void setup() {
Serial.begin(115200);
Serial.println("Print number of character from input.");
pinMode(buttonPin, INPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
Serial.println("Button pressed. #bytes received:");
int numBytes = Serial.available();
Serial.println(numBytes);
while (digitalRead(buttonPin));
}
}
[/code]
Now I tested various situations:
- Communicating through USB in SerialMonitor from the arduino SDK: Works as expected.
- Communicating through USB in my C# program: Works as expected.
- Communicating with Bluetooth in SerialMonitor: SerialMonitor wont start, and COM4 is suddenly removed from the list in the Arduino editor. Maybe this is normal behaviour though (?).
- Communcating with Bluetooth in my C# program: Works from MCU to PC. It will print that 0 characters have been received, but when I sent data from PC to MCU, it resets the device, and I will see the text from setup() again.
Note that I removed the USB connector when testing with bluetooth, to be sure no USB communication is messing things up.
The fact that everything works ok with USB indicates to me that the code itself is fine.
I prefer not to use bluesoleil, otherwise I have to use (and buy) that program for each PC. It should really be possible to work without being forced to buy another program.
kind regards,
kthxbai