i am using Arduino uno r4 minima. i have simple code of hello world..
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("hello world");
}
void loop() {
// put your main code here, to run repeatedly:
}
no output in serial monitor
same code is working in arduino uno r3 .
In contrast to the UNO R3, the R4 has a native USB interface. After Serial.begin() you have to wait until the USB communication is established. Then you can print ( because of the native USB the baud rate has no meaning ).
Try:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while(!Serial); // Wait until USB communication is ready
Serial.println("hello world");
}
void loop() {
// put your main code here, to run repeatedly:
}
N.B. Despite of the very similar name ( UNO R3 <-> UNO R4 ), be aware that he R4 ist technically a completely different board.
I can verify, as I expected, that the sketch shown in post #1 produced no output on my R4 Minima. Not even after pressing the reset button. I have minicom connected to /dev/ttyACM0, which automatically reconnects after the upload is complete.
However, the following does show "hello world", both after uploading, and after pressing reset:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while(!Serial);
Serial.println("hello world");
}
void loop() {
// put your main code here, to run repeatedly:
}
Running the sketch shown in post #6 showed the following:
In the UNO R3, the UART handles serial communication by transmitting bytes without concern for the receiver’s status or whether anyone is listening.
The UNO R4 communicates over USB, which involves a negotiation process between the computer and the Arduino when the connection is established. This negotiation occurs at the hardware level and takes time, meaning your Arduino code must wait until the Serial connection is ready before using it.
That’s what the line
while(! Serial) ;
It polls the status of the Serial line and returns true when the link works. You can keep it on the R3 and it always says true right away, on the R4 - as explained - it will take a bit of time.