does someone know why the code hang up until serial monitor launch?
I've bluetooth device to receive the data from arduino.
But it have nothing until i lauch the serial monitor from arduino IDE.
Here is the source code.
#define BAUD_RATE_BLE 9600
void setup() {
// put your setup code here, to run once:
Serial.begin( BAUD_RATE_BLE); // bt
delay(2000);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("loop");
delay(2000);
}
Well your code doesn't actually do anything except serial prints, so the only way you will know it's working is if you activate the monitor.
I doubt if it's hanging: I'm pretty sure if you put a few lines in setup() to turn an LED on and off, you'll see that happen even before you open the monitor.
Remember that opening the monitor resets the Arduino: so when you upload the code it starts to print to serial even though you didn't yet open the monitor. Then when you open the monitor the sketch starts again, so that may be why you think it was hanging: you actually only see the output from the restart, not the original start.
JimboZA:
Well your code doesn't actually do anything except serial prints, so the only way you will know it's working is if you activate the monitor.
I doubt if it's hanging: I'm pretty sure if you put a few lines in setup() to turn an LED on and off, you'll see that happen even before you open the monitor.
Remember that opening the monitor resets the Arduino: so when you upload the code it starts to print to serial even though you didn't yet open the monitor. Then when you open the monitor the sketch starts again, so that may be why you think it was hanging: you actually only see the output from the restart, not the original start.
Hi JimboZA,
many thanks.
actually, i use BLUNO borad(UNO+Bluetooth Low Engery module) to develop.
that's why our code only do serial prints.
Then i expect our app(ble device) can receive those data.
But just like i said,
our app can receive those data until serial monitor launch.
do you have any workaround/suggestion to avoid this situation?
(should launch serial monitor first, then do our code)