Sketch (blink) uploads and works OK, but when uploading starts, it plays an audible warning (the same as when the arduino usb disconnects from the computer), it does not report any errors but serial communication does not work. I can't find a problem.
Thanks.
And both leds Tx and Rx are constantly on.
Disconnect the USB-serial adaptor from the Arduino but plug into PC. Use a wire to connect Rx to Tx on the adaptor. From serial monitor, type some text and hit enter. Do you see the text you entered repeated back in serial monitor?
I dont't have a USB serial adaptor. my Pro Mini is with micro usb.
Is there any other way to do this?
So you have a Pro Micro, not a Pro Mini.
Sorry, yes it is a Pro Micro.
I'm using the Leonardo and it toggles from Arduino Leonardo to Arduino Leonardo (Boot loader) when uploading; and back to Arduino Leonardo after that. I'm reasonably sure that it's the same for the Pro Micro (if that is what you have) so the connect/disconnect sounds are normal.
If you're using Windows, you can observe the behaviour in device manager; not sure about other operating system (probaly use lsusb and dmesg).
Not sure why your RX and TX leds are permanently on.
sterretje:
I'm using the Leonardo and it toggles from Arduino Leonardo to Arduino Leonardo (Boot loader) when uploading; and back to Arduino Leonardo after that. I'm reasonably sure that it's the same for the Pro Micro(if that is what you have)so the connect/disconnect sounds are normal
Yes, Leonardo and Pro Micro are very similar in this respect. They have the same MCU chip. This is normal behaviour for them. Post your sketch. There are some extra lines of code that are needed for Leonardo/Pro Micro.
I upload these code and now serial window works with all bauds.
I don't know what went wrong, thanks for the help.
void setup() {
Serial.begin(9600);
pinMode(10, OUTPUT);
}
void loop() {
digitalWrite(10, HIGH);
Serial.println("HIGH");
delay(1500);
digitalWrite(10, LOW);
Serial.println("LOW");
delay(500);
}
Please post code as described in the forum guide.
That extra line of code needed with Leonardo/Pro Micro I mentioned is missing from your code. Your code may be working by luck. Add this line just after Serial.begin().
while (!Serial) ;
I added this line and now Serial.println () also works in Setup () which didn't work before, but I didn't notice it at the time. Thank you.
In another project I also use Serial1 for Bluetooth modul.
Does Serial1 also need this command?
void setup() {
Serial.begin(9600);
while(!Serial);
Serial1.begin(38400);
while(!Serial1);
pinMode(10, OUTPUT);
}
.........
No, I'm pretty sure that won't be needed for Serial1, but it won't do any harm, so leave it in.
P.S.
PaulRB:
Please post code as described in the forum guide.
OK thanks.
while(!Serial) is only needed for native USB connections if (and only if) your sketch needs to wait for a PC to be connected. On you board, that will be Serial, not Serial1).
To my knowledge, without it, you can miss the initial output of the sketch but the Arduino should eventually start sending out the data if the PC is connected.
And with a stand-alone Arduino (externally powered, not connected to the PC), your sketch will hang forever on while(!Serial) till you connect the Arduino to the PC (and possibly open a terminal program, not 100% sure).
Be aware that disconnecting an externally powered board (that is sending data to the PC after it was connected to the PC) from the PC can bring the board to a near grinding halt; the solution is to use Serial.availableForWrite() to check if you can send. See Serial.print on Leonardo very slow after disconnection from serial for more details.